Insert block to existing block insertion points

Insert block to existing block insertion points

Anonymous
Not applicable
966 Views
3 Replies
Message 1 of 4

Insert block to existing block insertion points

Anonymous
Not applicable

Hello everyone Smiley Happy

 

I have these dynamic blocks (blk01, blk02, blk03) scattered all over the drawing.

I need to insert a new block (blkAA) from C:\folder1\folder\blkAA.dwg into each found dynamic blocks (blk01, blk02, blk03) insertion point.

 

Its kinda like block replace routine but I'm still keeping the existing blocks in the drawing.

 

Please help! Thanks in advance Smiley Happy

0 Likes
Accepted solutions (1)
967 Views
3 Replies
Replies (3)
Message 2 of 4

hmsilva
Mentor
Mentor
Accepted solution

Hi JCprog,

 

untested...

 

(defun c:demo (/ ss blk obj)
  (if (and (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 "BLK01,BLK02,BLK03,`*U*") (cons 410 (getvar 'CTAB)))))
           (setq blk (findfile "C:\\folder1\\folder\\blkAA.dwg"))
      )
    (repeat (setq i (sslength ss))
      (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
      (if (wcmatch (strcase (vla-get-effectivename obj)) "BLK01,BLK02,BLK03")
        (command "-insert" blk "_S" 1 "_R" 0 "_NONE" (vlax-get obj 'InsertionPoint))
      )
    )
  )
  (princ)
)

 

 

Henrique

EESignature

0 Likes
Message 3 of 4

Anonymous
Not applicable

That works perfectly!!!!!!!!! Smiley Very Happy

 

Thanks a million Henrique!

0 Likes
Message 4 of 4

hmsilva
Mentor
Mentor
You're welcome, JCprog
Glad I could help

Henrique

EESignature

0 Likes