Jord_91 Posted February 16, 2018 Share Posted February 16, 2018 HI, I would like to add suffix to the text in multiple files at once. ex: the name is "ml153029ar" and I need to add "OVA" at the end but every name in the different drawing are different sort i can't just make a find and replace. Help me please! Quote Link to comment Share on other sites More sharing options...
rlx Posted February 16, 2018 Share Posted February 16, 2018 I am working on a program that can read a users brain but at this time it only works for my mind. So either you donate your brain to me or you could provide a little bit more detailed info on your question. To get you started , are the text's always on the same layer , or is it an attribute in a block , do they allways start with ml , are they of a fixed length or of a certain format that can be use in combination with wcmatch? gr. Rlx Quote Link to comment Share on other sites More sharing options...
Jord_91 Posted February 16, 2018 Author Share Posted February 16, 2018 Rlx, Good idea for the mind reader;) In fact, all the text are on the Layers: ''2D'' and Start with ML and it's followed by a suite of letters and different numbers that are ALWAYS DIFFERENT and has NOT the same lenght. I looked to the wcmatch and it's not possible to math i would like to do. It doesn't matter if it's a simple routine that I can modify and run in Script pro.. I don't know... Lee mac has something to add suffix but the problem with it is that you have to run it one file at the time because you need to select the text. ;; (pstext "Prefix Text" "Suffix Text" );; ;; = 0 - single selection ;; = 1 - window selection ;; ;; Author: Lee Mac 2011 - http://www.lee-mac.com (defun pstext ( preftext sufftext mode / a e i s ) (cond ( (= 1 mode) (while (progn (setvar 'ERRNO 0) (setq e (car (nentsel))) (cond ( (= 7 (getvar 'ERRNO)) (princ "\nMissed, try again.") ) ( (eq 'ENAME (type e)) (if (wcmatch (cdr (assoc 0 (entget e))) "TEXT,MTEXT,ATTRIB") (entmod (setq e (entget e) a (assoc 1 e) e (subst (cons 1 (strcat preftext (cdr a) sufftext)) a e) ) ) (princ "\nInvalid Object.") ) ) ) ) ) ) ( (setq s (ssget "_:L" (list '(0 . "TEXT,MTEXT")))) (repeat (setq i (sslength s)) (entmod (setq e (entget (ssname s (setq i (1- i)))) a (assoc 1 e) e (subst (cons 1 (strcat preftext (cdr a) sufftext)) a e) ) ) ) ) ) (princ) ) (defun c:OVATEXT ( ) (pstext "" "OVA" 1) ) Thanks! Ps. sorry for my bad english i'm French... Quote Link to comment Share on other sites More sharing options...
rlx Posted February 16, 2018 Share Posted February 16, 2018 I will try not to hold it against you , that you're French haha , just kidding... But getting the right text should be easy then , you would just have to test if it starts with ml (or ML) (if (wcmatch (strcase txt) "ML*") .... Quote Link to comment Share on other sites More sharing options...
Jord_91 Posted February 16, 2018 Author Share Posted February 16, 2018 So i put this in my actual lisp just after pstext ??... Ok Ok I like the idea of Lisp but i'm a noob at it. I have made a lot of Macro command but lisp are clearly more complicated!! Quote Link to comment Share on other sites More sharing options...
rlx Posted February 16, 2018 Share Posted February 16, 2018 (edited) try this : ;; (pstext "Prefix Text" "Suffix Text" <mode>) ;; ;; <mode> = 0 - single selection ;; = 1 - window selection ;; ;; Author: Lee Mac 2011 - www.lee-mac.com (defun pstext (preftext sufftext mode / a e i s txt) (cond ((= 0 mode) (while (progn (setvar 'errno 0) (setq e (car (nentsel))) (cond ((= 7 (getvar 'errno)) (princ "\nMissed, try again.")) ((eq 'ename (type e)) (ctxt e)))))) ((setq s (ssget "_:L" (list '(0 . "TEXT,MTEXT")))) (repeat (setq i (sslength s))(ctxt (ssname s (setq i (1- i)))))) ) (princ) ) (defun ctxt (e) (if (and (member (cdr (assoc 0 (setq e (entget e)))) '("TEXT""MTEXT""ATTRIB")) (wcmatch (strcase (setq txt (cdr (assoc 1 e)))) "ML*")) (entmod (setq e (subst (cons 1 (strcat preftext txt sufftext)) (assoc 1 e) e)))) ) (defun c:ovatext () (pstext "" "OVA" 1)) Edited February 16, 2018 by rlx Quote Link to comment Share on other sites More sharing options...
Jord_91 Posted February 16, 2018 Author Share Posted February 16, 2018 It don't work, The selection cycle is in the PSTEXT so if we find the text before and run a function to find another text somwhere else it won't work... I think Quote Link to comment Share on other sites More sharing options...
rlx Posted February 16, 2018 Share Posted February 16, 2018 It don't work, The selection cycle is in the PSTEXT so if we find the text before and run a function to find another text somwhere else it won't work... I think the functions as it is written by Lee in it's current form lets you pick one text at the time only. You want it to operate on a complete drawing or folder? Quote Link to comment Share on other sites More sharing options...
Jord_91 Posted February 16, 2018 Author Share Posted February 16, 2018 In fact, it was an example of a function and I tought that it might have worked but I can be totaly wrong! In the best case i would be able to run it on an entire folders sort that every files would be modify adding the suffix. But if it’s not possible, I would like to change on a complete drawing and I will run it in a program to run it on every files. Thx, I hope it’s clear enough Quote Link to comment Share on other sites More sharing options...
rlx Posted February 16, 2018 Share Posted February 16, 2018 oops , I just realized I only changed one half of Lee's function. I have updated the code from post #6 , try again... Quote Link to comment Share on other sites More sharing options...
Jord_91 Posted February 16, 2018 Author Share Posted February 16, 2018 I’ll look at it on monday thx Quote Link to comment Share on other sites More sharing options...
rlx Posted February 16, 2018 Share Posted February 16, 2018 (edited) Have a good weekend. Added odbx version to process entire folder Gr. Rlx Jord_91_OvaText.lsp Edited February 17, 2018 by rlx Quote Link to comment Share on other sites More sharing options...
Steven P Posted February 17, 2018 Share Posted February 17, 2018 Whoops - I was about to suggest bfind but then I read the question again. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 18, 2018 Share Posted February 18, 2018 (edited) I think some times people put to much emphasis on must work over multiple drawings will be slow, a script will open a dwg run a lisp and close again pretty fast, repeating as required. If you have hundreds then yes look ODBX. a script like open dwg1 (load "Rlx-LEE-suffix) close Y open dwg2 (load "Rlx-LEE-suffix) close Y open dwg3 (load "Rlx-LEE-suffix) close Y If the dwg's are in known directories and like me know a few old DOS tricks you can make the script in a couple of minutes. DIR *.DWG >myscipt.scr /b Edited February 18, 2018 by BIGAL Quote Link to comment Share on other sites More sharing options...
rlx Posted February 18, 2018 Share Posted February 18, 2018 (edited) I think some times people put to much emphasis on must work over multiple drawings will be slow, a script will open a dwg run a lisp and close again pretty fast, repeating as required. If you have hundreds then yes look ODBX. a script like open dwg1 (load "Rlx-LEE-suffix) close Y open dwg2 (load "Rlx-LEE-suffix) close Y open dwg3 (load "Rlx-LEE-suffix) close Y If the dwg's are in known directories and like me know a few old DOS tricks you can make the script in a couple of minutes. DIR *.DWG >myscipt.scr /b It's not like I'm force feeding anyone to use my code but I get your point bigal haha. I always look for the option that it the easiest for me and in this case I already had a routine in my editor to change the textstyle so this was just a case of me being lazy In my 'defence' (not implying I have to) I usualy work with hundreds of drawings and sometimes hundreds of thousands so for me speed is key. But I have many ways , scripts , odbx , coreconsole and of cource my 'tape deck buttons' so I press the button for next drawing , press button with srcipt and I'm done , next drawing ... all with one hand supporting my big giant head and a mouse in the other Edited February 18, 2018 by rlx Quote Link to comment Share on other sites More sharing options...
Jord_91 Posted February 22, 2018 Author Share Posted February 22, 2018 You clearly Rock man. It works as a charm. I have create a new post about running a .scr ofr multiple files if you have the time to have a look at it it would be appreciated. I made my very best but some time it doesn't work. I'm on my way to learn how to create lisp but to me it's clearly mode complicated then a macro or a Script. Anyway, Thanks and have a good day. Quote Link to comment Share on other sites More sharing options...
rlx Posted February 22, 2018 Share Posted February 22, 2018 You clearly Rock man. It works as a charm. I have create a new post about running a .scr ofr multiple files if you have the time to have a look at it it would be appreciated. I made my very best but some time it doesn't work. I'm on my way to learn how to create lisp but to me it's clearly mode complicated then a macro or a Script. Anyway, Thanks and have a good day. gosh you make me blush (or were you talkin' about bigal ) will try to find some time (or a tardis) for your other request. gr. Rlx Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.