Jump to content

Recommended Posts

Posted

Need a lsp which is allow me to select an particular text in all layouts tabs at once.

Posted

There's ways to modify, but I don't believe you can select objects in multiple layouts at the same time.

Posted
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.

Posted


(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)
)

 

Posted

@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.

Posted

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.

Posted (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 by pmadhwal7
Posted

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.

Posted

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.

Posted

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

Posted (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 by rlx
Posted

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

  • Like 1
Posted

If it is an attribute then much easier to do. Have some sample lisps.

Posted
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...

Posted
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...

Posted
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.

  • Like 1
Posted
4 minutes ago, BIGAL said:

Nice one rlx (cons 1 "#*of #*") will try to remember that 

 

Thanx Bigal  :beer:  it's probably not full proof but in this case it seems to get the job done.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...