Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help - changing layers of blocks with attributes

3 REPLIES 3
Reply
Message 1 of 4
tracihabergham
347 Views, 3 Replies

Help - changing layers of blocks with attributes

I am writing an autolisp programme to enable users to change the layers (& colour) of a block by clicking on it. This works on simple blocks that have no attributes but the ones with attribute don't work! They change layers but not their colours as required.

Can anybody help. I am using the entmod command and substituting the layer (8 . "whatever") to (8 . "0").

Thank you
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: tracihabergham

Look into the (entupd) function.
--
Bobby C. Jones

"tracihabergham" wrote in message
news:f06036f.-1@WebX.maYIadrTaRb...
> I am writing an autolisp programme to enable users to change the layers (&
colour) of a block by clicking on it. This works on simple blocks that have
no attributes but the ones with attribute don't work! They change layers but
not their colours as required.
> Can anybody help. I am using the entmod command and substituting the layer
(8 . "whatever") to (8 . "0").
>
> Thank you
>
>
Message 3 of 4
Anonymous
in reply to: tracihabergham

Attributes are stored as separate entities following the insert. If
you want to change the layer of the attributes as well, you need to
process them individually.

It's not necessary to pass an entire entity association list to (entmod
..), and using the (subst ...) function is a waste of time (in this
case).

Something like (untested):

(while (/= countfurn exfurn_number)

(setq InsertName (ssname exfurn countfurn)
EntityList (entget EntityName)
)
;; Change the block insert's layer
(entmod (list (cons -1 InsertName) layerfurn))
;; If the insert has attributes ...
(if (= 1 (cdr (assoc 66 EntityList)))
;; Loop over all attributes ...
(while (/= "SEQEND"
(cdr
(assoc 0
(setq EntityList
(entget (entnext (cdr (assoc -1 EntityList))))
)
)
)
;; Change the attribute's layer
(entmod (list (assoc -1 EntityList) layerfurn))
)
)
;; Change the layer of the SEQEND entity
(entmod (list (assoc -1 EntityList) layerfurn))
;; Update the block on screen
(entupd InsertName)

(setq countfurn (+ 1 countfurn))

jrf
Member of the Autodesk Discussion Forum Moderator Program

In article , Tracihabergham wrote:
> I am writing an autolisp programme to enable users to change the
> layers (& colour) of a block by clicking on it. This works on simple
> blocks that have no attributes but the ones with attribute don't
> work! They change layers but not their colours as required.
> Can
> anybody help. I am using the entmod command and substituting the
> layer (8 . "whatever") to (8 . "0").
> Thank you
>
>
> [Attachment
> decoded to FILE://\VA\attachments\exfurniture.lsp]
>
Message 4 of 4
Anonymous
in reply to: tracihabergham

Whoops, the SEQEND entity layer change was in the wrong place

(while (/= countfurn exfurn_number)

(setq InsertName (ssname exfurn countfurn)
EntityList (entget EntityName)
)
;; Change the block insert's layer
(entmod (list (cons -1 InsertName) layerfurn))
;; If the insert has attributes ...
(if (= 1 (cdr (assoc 66 EntityList)))
(progn
;; Loop over all attributes ...
(while (/= "SEQEND"
(cdr
(assoc 0
(setq EntityList
(entget
(entnext
(cdr (assoc -1 EntityList))
)
)
)
)
)
;; Change the attribute's layer
(entmod (list (assoc -1 EntityList) layerfurn))
)
)
;; Change the layer of the SEQEND entity
(entmod (list (assoc -1 EntityList) layerfurn))
)
)
;; Update the block on screen
(entupd InsertName)

(setq countfurn (+ 1 countfurn))
)

jrf
Member of the Autodesk Discussion Forum Moderator Program

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost