
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear All,
I have been running an autolisp program (courtsey by some user online) for Find and replace for 'Normal Text' and 'Attribute Text Value' based on input provided in 'x.xls' file. It works absoulety fine with 'Normal Text' replacment (a different lisp not attached here) but when it comes to find and replacement of 'Attribute Text value' it replaces 'Attribute Tag' and infact 'Default/Text Value' remain unchanged. Please help & correct the attached code, would be great help I have to run this program in more than 80 files for 'Attribute Text values' change.
(defun FLNG_PutAtt(dataList)
;;;--- Set up a revised attVal counter
(setq attValCnt 0)
;;;--- Update progress
(princ "\n Getting Block information...")
;;;--- Get a selection set of all blocks
(if(setq eset(ssget "X" (list (cons 0 "INSERT"))))
(progn
;;;--- Set up a counter
(setq cntr 0)
;;;--- Update progress
(princ "\n Processing attributes...")
;;;--- Cycle through each entity
(while (< cntr (sslength eset))
;;;--- Get the name of the first entity
(setq en(ssname eset cntr))
;;;--- Get the dxf group codes of the entity
(setq enlist(entget en))
;;;--- If the block contains attributes
(if(= 1 (cdr(assoc 66 enlist)))
(progn
;;;--- Get the name of the sub-entity
(setq en2(entnext en))
;;;--- Get it's dxf group codes
(setq enlist2(entget en2))
;;;--- Loop until SEQEND is found
(while(/= "SEQEND" (cdr(assoc 0 enlist2)))
;;;--- Make sure it is an attribute
(if(= "ATTRIB" (cdr(assoc 0 enlist2)))
(progn
(setq attVal(cdr(assoc 2 enlist2)))
(setq oldVal(cdr(assoc 1 enlist2)))
(foreach a dataList
(if(= (strcase attVal)(strcase (car a)))
(progn
(cond
((= nil (cadr a))(setq newVal " "))
((= (read "REAL") (type (cadr a)))(setq newVal(vl-princ-to-string (cadr a))))
((= (read "INT") (type (cadr a))) (setq newVal(itoa (cadr a))))
(T (setq newVal (cadr a)))
)
(setq enlist2(subst (cons 1 newVal)(assoc 1 enlist2)enlist2))
(entmod enlist2)
(entupd en2)
(princ (strcat "\n Changed Value of Attribute: " attVal " From: " oldVal " To: " newVal))
(setq attValCnt(+ attValCnt 1))
)
)
)
(setq en2(entnext en2))
(setq enlist2(entget en2))
)
)
)
)
)
(setq cntr(+ cntr 1))
)
)
(alert "No blocks found in drawing!")
)
(princ (strcat "\n Revised (" (itoa attValCnt) ") attributes!"))
(princ)
)
Running only in model space, Acad ver 2010, these are Text and Mtext both.
Would sincerely appreicate if some one could help me on this?
- TOMES
Solved! Go to Solution.