pmadhwal7 Posted October 7, 2019 Posted October 7, 2019 Need a lsp which is allow me to select an particular text in all layouts tabs at once. Quote
tombu Posted October 7, 2019 Posted October 7, 2019 There's ways to modify, but I don't believe you can select objects in multiple layouts at the same time. Quote
Roy_043 Posted October 7, 2019 Posted October 7, 2019 1 hour ago, tombu said: but I don't believe you can select objects in multiple layouts at the same time. Sure you can. But you must then process the selected entities programmatically without using command calls. Quote
rlx Posted October 7, 2019 Posted October 7, 2019 (defun c:t1 (/ ss txt i e edat s) (defun *error* (msg) (princ msg)) (cond ((not (setq txt (getstring "\nString to search : "))) (alert "No text was specified")) (t (setq txt (strcase (strcat "*" txt "*"))) (foreach lay (cons "Model" (layoutlist)) (setvar "CTAB" lay) (if (setq ss (ssget "X" (list '(0 . "TEXT") (cons 410 (getvar "CTAB"))))) (repeat (setq i (sslength ss)) (setq e (ssname ss (setq i (1- i))) edat (entget e) s (cdr (assoc 1 edat))) (if (wcmatch (strcase s) txt) (command "chprop" e "" "col" 1 "") ) ) ) (setq ss nil) ) ) ) (princ) ) Quote
Roy_043 Posted October 8, 2019 Posted October 8, 2019 @rlx Yes of course that would be a possibility. I must admit I never do this. Anyway the OP is terribly vague, I don't know what the goal is here. BTW: getstring will not return nil. Quote
rlx Posted October 8, 2019 Posted October 8, 2019 Yeah you're right about the getstring , was more sort of cancel related and could have added check for empty string "" or "*" to be able to select all strings but decided to leave it with that because of as you say the vagueness of the request so expected it to be one of those snowball questions where every solution generates another question / request haha. Quote
pmadhwal7 Posted October 8, 2019 Author Posted October 8, 2019 (edited) 12 hours ago, rlx said: (defun c:t1 (/ ss txt i e edat s) (defun *error* (msg) (princ msg)) (cond ((not (setq txt (getstring "\nString to search : "))) (alert "No text was specified")) (t (setq txt (strcase (strcat "*" txt "*"))) (foreach lay (cons "Model" (layoutlist)) (setvar "CTAB" lay) (if (setq ss (ssget "X" (list '(0 . "TEXT") (cons 410 (getvar "CTAB"))))) (repeat (setq i (sslength ss)) (setq e (ssname ss (setq i (1- i))) edat (entget e) s (cdr (assoc 1 edat))) (if (wcmatch (strcase s) txt) (command "chprop" e "" "col" 1 "") ) ) ) (setq ss nil) ) ) ) (princ) ) Sir the code you posted is changing colour of the text and I want to select the entity and export it to excel or change the layers or anything else... please help me just like select similar command Edited October 8, 2019 by pmadhwal7 Quote
rlx Posted October 8, 2019 Posted October 8, 2019 Like a said a snow ball question haha. Code was meant as a learning example, for those willing... Have a look at it later , first have little job to do now. An example of your drawing and how the output should look like would be helpful since I only use my mindreading powers in a casino. Quote
rlx Posted October 8, 2019 Posted October 8, 2019 if my eye is not deceiving me Sheet No. is just a separate text object and you want the text next to it , same for Patch Length. Or even 'worse' , the text's you want are attributes? Need dwg and output format, either posted here or as P.M. , else no-can-do. Quote
pmadhwal7 Posted October 8, 2019 Author Posted October 8, 2019 Yes sir like sheet number text highlights after selection the same process I want to in all layouts, select it and export to excel or change the layers of particular object attachment is available example.dwg Quote
rlx Posted October 8, 2019 Posted October 8, 2019 (edited) To get you started. Barely tested (I'm a little busy at the moment) (defun c:t2 (/ ss1 ss2 i result-list) (vl-load-com) (defun *error* (msg) (princ msg)) (foreach lay (layoutlist) (setvar "CTAB" lay) (and (setq ss1 (ssget "_X" (list (cons 0 "*TEXT")(cons 1 "Patch Length*")(cons 410 (getvar "CTAB"))))) (setq ss2 (ssget "_X" (list (cons 0 "*TEXT")(cons 1 "#*of #*")(cons 410 (getvar "CTAB"))))) (setq result-list (cons (list (ssname ss2 0)(ssname ss1 0)) result-list)) ) (setq ss1 nil ss2 nil) ) (if (yes_no "Change layer?") (chg_lay result-list)) (if (yes_no "Write to csv file?") (csv-lst result-list)) (princ) ) (defun chg_lay (lst / new-lay pair item) (setq new-lay (getstring "\nEnter new layer : ")) (if (and (vl-consp lst) new-lay (not (eq new-lay "")) (tblsearch "layer" new-lay)) (foreach pair lst (foreach item pair (vla-put-layer (vlax-ename->vla-object item) new-lay))) ; remove complete cond if you want no error message when something went wrong (cond ((null new-lay)(princ "\nLayername kaput")) ((eq new-lay "")(princ "\nLayername void")) ((not (tblsearch "layer" new-lay))(princ (strcat "\nLayer name " new-lay " not present in drawing"))) ((not (vl-consp lst))(princ "\nEmpty bucketlist")) (t (princ "\nDunno what's wrong, just know it is")) ); end cond ) (princ) ) (defun csv-lst (lst / csv-fn csv-fp pair item) (cond ((not (vl-consp lst))(princ "\nEmpty bucketlist")) ((not (setq csv-fn (getfiled "Enter name for (new) csv file" (getvar 'dwgprefix) "csv" 1))) (princ "\nNo name was provided for csv file")) ((not (setq csv-fp (open csv-fn "w")))(princ "\nUnable to create csv file")) (t (foreach item lst (write-line (strcat (cdr (assoc 1 (entget (car item)))) ";" (cdr (assoc 1 (entget (cadr item))))) csv-fp)) ) ) (if csv-fp (progn (close csv-fp)(gc))) (if (and csv-fn (setq csv-fn (findfile csv-fn)))(startapp "notepad" csv-fn)) ) ; (yes_no "Do you like snow") (defun yes_no ( $m / f p i r ) (and (= (type $m) 'STR) (setq f (vl-filename-mktemp ".dcl")) (setq p (open f "w")) (write-line (strcat "yesno:dialog{label=\"" $m "?\";ok_cancel;}") p) (progn (close p)(gc) t) (setq i (load_dialog f)) (new_dialog "yesno" i) (progn (action_tile "accept" "(done_dialog 1)")(action_tile "cancel" "(done_dialog 0)") (setq r (start_dialog))(unload_dialog i)(vl-file-delete f) t)(if (= r 1) t nil))) Edited October 8, 2019 by rlx Quote
rlx Posted October 8, 2019 Posted October 8, 2019 then you haven't cut-copy-pasted the code right and your missing probable the last ) have attached the file. gotta go now.... Pmadhwal7.lsp 1 Quote
BIGAL Posted October 9, 2019 Posted October 9, 2019 If it is an attribute then much easier to do. Have some sample lisps. Quote
pmadhwal7 Posted October 9, 2019 Author Posted October 9, 2019 14 hours ago, rlx said: then you haven't cut-copy-pasted the code right and your missing probable the last ) have attached the file. gotta go now.... Pmadhwal7.lsp 3.09 kB · 2 downloads i don't want to change the color i just want to select that text after that i can delete or export to the excel for any type of error checking... Quote
pmadhwal7 Posted October 9, 2019 Author Posted October 9, 2019 3 hours ago, BIGAL said: If it is an attribute then much easier to do. Have some sample lisps. no sir it's a text... Quote
rlx Posted October 9, 2019 Posted October 9, 2019 4 minutes ago, pmadhwal7 said: i don't want to change the color i just want to select that text after that i can delete or export to the excel for any type of error checking... All the text's are in a variable 'result-list' , in the program I just gave you 2 options what you can do with with them, change layer or export. What you want to do next with them is entirely up to you. 1 Quote
BIGAL Posted October 9, 2019 Posted October 9, 2019 Nice one rlx (cons 1 "#*of #*") will try to remember that Quote
rlx Posted October 9, 2019 Posted October 9, 2019 4 minutes ago, BIGAL said: Nice one rlx (cons 1 "#*of #*") will try to remember that Thanx Bigal it's probably not full proof but in this case it seems to get the job done. Quote
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.