Batch lisp to change a Tag value in multiple drawings

Batch lisp to change a Tag value in multiple drawings

francine.zimmermannSRSWJ
Advocate Advocate
390 Views
3 Replies
Message 1 of 4

Batch lisp to change a Tag value in multiple drawings

francine.zimmermannSRSWJ
Advocate
Advocate

I have hundreds of drawings/blocks where I need to change the tag value, specifically replacing the comma with a dot.

For example see attached drawing TM-SAV-A4-021, where should I change the comma in the TAG: MONITOR 

Savis. A4 4,2x13 ISO14585 -> Savis. A4 4.2x13 ISO14585 

I tried using Lee Mac's Lisp https://www.lee-mac.com/bfind.html , but it doesn't work.

Is there another solution without having to open each drawing?

0 Likes
391 Views
3 Replies
Replies (3)
Message 2 of 4

paullimapa
Mentor
Mentor

Perhaps reading this recent post would help


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 4

Sea-Haven
Mentor
Mentor

1st step would be to make the screw and attributes a proper block. That way block has a proper name and simple to get correct attribute.  Is this a true representation of an actual block in the dwg ?

 

Any way maybe something like this. save it as a lsp file.

(defun wow ( / ss txt ent )
(setq ss (ssget "X" '((0 . "ATTDEF")(2 . "MONITOR"))))
(if ss 
 (repeat (setq x (sslength ss))
  (setq ent (entget (ssname ss (setq x (1- x)))))
  (setq txt (cdr (assoc 1 ent)))
  (setq txt (vl-string-subst "." "," txt))
  (entmod (subst (cons 1 txt)(assoc 1 ent) ent))
 )
)
(princ)
)
(wow)

 

The script, just replace my lisp with your lisp name including path. Use "\\" in path.

open dwg1
(load "mylisp")
close
y
open dwg2
(load "mylisp")
close
y
repat as required

 

0 Likes
Message 4 of 4

paullimapa
Mentor
Mentor

Try the attached lisp function modified from @komondormrex mass_change_att function he coded from post I previously mentioned.

Saved attached lisp to folder that's added to Options>Files>Support File Search Path

Then at command prompt enter:

(load "mass_change_att")
(mass_change_att "TM-SAV-A4-021" "MONITOR" "," ".")

Next select folder containing all drawings you want to search attribute value for comma & replace with period.

Note: Make sure none of the dwgs in that folder is currently opened.

Found attribute values in dwg will show up on command prompt:

paullimapa_0-1758123734153.png

 

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes