We have a series of blocks on a drawing. All listed as Balloon. I need to
rename them all to GENPOS14.
What is the command for this.
And Part2...
I need to rename the attributes inside each block.
They are currently listed as S1, S2, S3, etc.
And I need them to be 1genpos, 2genpos, 3genpos, etc.
Thanks
Chris
What about the RENAME command? (or DDRENAME)? In a script, you could use
RENAME.
> I need to rename the attributes inside each block.
>
> They are currently listed as S1, S2, S3, etc.
>
> And I need them to be 1genpos, 2genpos, 3genpos, etc.
If you do not care what the Entity Handle of the block insert is (most people
do not), and you do not need to run from a script, use the ATTREDF.LSP
program. Do _not_ use the one that shipped with R14, download it from
Autodesk's web site.
If you do need to run from a script, try something like (untested):
(defun C:RenameTags
(/ Elist TagNamesList BlockName NewTag SelSet Counter)
;; Define a list containing pairs of "old tag name"
;; and "new tag name". A new tag name may appear more
;; than once, but the old tag name may only appear
;; once (or only the first occurrence will be used).
;; MUST BE ALL UPERCASE!
(setq TagNamesList
'(("S1" . "1GENPOS")
("S2" . "2GENPOS")
("S3" . "3GENPOS")
)
BlockName "BALLOON"
)
;; If the block is defined in the drawing ...
(if (setq EList (tblsearch "BLOCK" BlockName))
;; Sweep through all the block definitions ...
(progn
;; Get the first entity of the block
(setq EName (cdr (assoc -2 EList))
Elist (entget EName)
)
;; If the entity is an attribute definition
;; and we have a new tag for it ...
(if
(and (= "ATTDEF" (cdr (assoc 0 Elist)))
(setq NewTag (cdr (assoc (cdr (assoc 2 Elist)) TagnamesList)))
)
;; Modify it
(entmod (list (cons -1 EName) (cons 2 NewTag)))
)
;; Sweep through the rest of the entities in the block
(while (setq EName (entnext (cdr (assoc -1 EList))))
(setq EList (entget EName))
;; If this entity is an attribute definition
;; and we have a new tag for it ...
(if
(and (= "ATTDEF" (cdr (assoc 0 Elist)))
(setq
NewTag (cdr (assoc (cdr (assoc 2 Elist)) TagnamesList))
)
)
;; Modify it
(entmod (list (cons -1 EName) (cons 2 NewTag)))
)
)
)
)
;; OK, now for the inserts. If there are any
;; inserts of the block with attributes ...
(if (setq SelSet
(ssget "X"
(list '(0 . "INSERT") (cons 2 BlockName) '(66 . 1))
)
)
(progn
(setq Counter (sslength SelSet))
;; Loop over all the inserts
(while (<= 0 (setq Counter (1- Counter)))
;; Get the EAL of this insert
(setq EList (entget (ssname SelSet Counter)))
;; Loop over all the attributes
(while
(/=
"SEQEND"
(cdr
(assoc
0
(setq EList (entget (entnext (cdr (assoc -1 EList)))))
)
)
)
;; If there's a new tag for this attribute ...
(if (setq
NewTag (cdr (assoc (cdr (assoc 2 Elist)) TagnamesList))
)
;; Modify it
(entmod (list (assoc -1 EList) (cons 2 NewTag)))
)
)
)
)
)
(prin1)
)
jrf
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own