Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to rename a block. Please help ASAP

0 views
Skip to first unread message

chris

unread,
Feb 22, 1999, 3:00:00 AM2/22/99
to
We are trying to write a lisp to rename some blocks.

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

Jon Fleming

unread,
Feb 22, 1999, 3:00:00 AM2/22/99
to
In article <7arqpj$se...@adesknews2.autodesk.com>, Chris wrote:
> We are trying to write a lisp to rename some blocks.
>
> 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.

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


jos...@stargazer.net

unread,
Feb 23, 1999, 3:00:00 AM2/23/99
to
HI Chris To rename blocks use the Autocad RENAME command. To modify
attributes in an existing block use the Autocad command ATTREDEF. Good Luck
Joseph E. Willis In article <7arqpj$se...@adesknews2.autodesk.com>,
"chris" <ch...@ftii.com> wrote: > We are trying to write a lisp to rename

some blocks. > > 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 > >

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

0 new messages