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

Replace a dynamic block definition

0 REPLIES 0
Reply
Message 1 of 1
CADVect
293 Views, 0 Replies

Replace a dynamic block definition

Hello together,

I use the follow program part to insert blocks and his definitions,
or replace this if the blocks already exist in my current drawing.

This works well if the block is not a dynamic.
If it is a dynamic block (example with a visibility parameter),
the else statement of (not (tblsearch "Block" newblknam) does not work completely. Because I delete all objects from the inside block definition and fill it with objects from the extern definition. The connection of the new objects to the inside visibility parameter be lost. It could possibly help if I can replace the inside visibility parameter with this of the outside. But this should happen also in the block DEFINITION not in the block reference. Unfortunately, I cannot find any suitable methods or properties in the block definition object. Can I find this perhaps in the dictionaries? And how can I get this methods? Many thanks for possible help! Regards

 

    (defun blkreplace (newblknam / )    
   
      (if (setq finlib (findfile "library.dwg"))
        (progn
          (setq docu (vla-get-activedocument (vlax-get-acad-object)))
          (setq odbx (vla-getinterfaceobject (vlax-get-acad-object) "ObjectDBX.AxDbDocument.19"))    
          (vla-open odbx finlib)
          (setq exblks (vla-get-blocks odbx))
          (setq inblks (vla-get-blocks docu))
          (setq extblk (vla-item exblks newblknam))
          (if (not (tblsearch "Block" newblknam))   
            (vla-copyobjects odbx (vlax-safearray-fill (vlax-make-safearray vlax-vbobject '(0 . 0)) (list extblk)) inblks)
            (progn
              (setq blkcou (vla-get-Count extblk))
              (setq intblk (vla-item inblks newblknam))
              (vlax-for blkele intblk
                (vla-Delete blkele)
              )
              (setq elearray (vlax-make-safearray vlax-vbobject (cons 0 (1- blkcou))) blklis nil)
              (vlax-for blkele extblk
                (setq blklis (append blklis (list blkele)))        
              ) 
              (vlax-safearray-fill elearray blklis)
              (vla-copyobjects odbx elearray intblk)
              (vlax-for blkele intblk
                (vla-Update blkele)
              )            
              (vlax-put-property intblk 'Explodable :vlax-false)
            )
          )    
          (vlax-release-object odbx)
          (command "Regen")
        )
      )
    )   

 

0 REPLIES 0

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

Post to forums  

Autodesk Design & Make Report

”Boost