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

Replace nested block

1 REPLY 1
Reply
Message 1 of 2
Redraiderr2009
434 Views, 1 Reply

Replace nested block

I have a dynamic block that has a nested temporary block inside it. What I am wanting to do is replace the temporary block with the permanent block. I have tried several different variation of coding but I cannot seem to get this bad boy to work. 

 

have used:

 

(vla-put-name (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) "tempBlockName") "newBlockName")

this gives me a duplicate names error. 

 

Any ideas?

1 REPLY 1
Message 2 of 2
Ian_Bryant
in reply to: Redraiderr2009

Hi,

try to replace tempBlockName with newBlockName

where tempBlockName is the name of a block nested

in the block definition of parentBlockName.

(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for ent
   (vla-item (vla-get-blocks doc) "parentBlockName")
   (if (and
          (= (vla-get-objectname ent) "AcDbBlockReference")
          (= (vla-get-name ent) "tempBlockName")
       )
       (vla-put-name ent "newBlockName")
   )
)
(vla-regen doc acAllViewports)

 

Ian

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

Post to forums  

Autodesk Design & Make Report

”Boost