Jump to content

Insert block on block


pmxcad

Recommended Posts

Hello,
I found a lisp on the internet that I would like to use.

What I want to achieve is that the lisp puts the block "Marker4.dwg on the blocks "U0003" insertionpoint, with the attribute tag "SYMBOOL_TOEVOEGING" and the value "EIDS" "ETV" " like test.dwg left side.

 

;Alan Henderson @ A'cad Solutions, Aug 18, 2004#3

(defun GetBlock (BlockName AttribName AttribValue /) 
;-----------------------------------------------------------
(setq cannsca (/ 1 (getvar "cannoscalevalue")))							;Get cannoscale
;-----------------------------------------------------------
(if (setq ss (ssget "X" (list (cons 0 "INSERT") (cons 2 BlockName)))) 
(progn 
(setq SSN (ssadd)) 
(setq KK 0 KS (sslength SS)) 
(setq BlocksFound 0) 
(while (< KK KS) 
(setq EG (entget (ssname SS KK))) 
(setq EN (entget (entnext (cdr (assoc -1 EG))))) 
(while (/= (cdr (assoc 0 EN)) "SEQEND") 
(if (and (= (cdr (assoc 2 EN)) AttribName) (= (cdr (assoc 1 EN)) 
AttribValue)) 
(progn 
(ssadd (cdr (assoc -1 EG)) SSN) 
(setq BlocksFound (1+ BlocksFound))
;-----------------------------------------------------------
(setq blkins (cdr (assoc 10 (entget (ssname ss 0)))))
(command "-insert" (strcat (getvar "dwgprefix") "Marker4.dwg") blkins cannsca "" "")		;Insert block "marker" 
;-----------------------------------------------------------
 
) 
) 
(setq EN (entget (entnext (cdr (assoc -1 EN))))) 
) 
(setq KK (1+ KK)) 
) 
) 
) 
(if SSN (princ (strcat "\n" (itoa BlocksFound) " Block(s) = " BlockName " 
with Attribute = " AttribName " & Value = " AttribValue " was Found!"))) 
(princ) 
)

;-----------------------------------------------------------            
(defun c:test ()
(GetBlock "U00003" "SYMBOOL_TOEVOEGING" "EIDS")
(GetBlock "U00003" "SYMBOOL_TOEVOEGING" "ETV")
);defun
;-----------------------------------------------------------            

I have already added some lines. (between the ;---------------------------------------------- ------------- lines)

As now the code insert only 1 block.
Who could help me, so the code inserts the "Marker4" block on each "U00003" block with value "EIDS" and "ETV".

 

 

thanks in advance

 

 

Marker4.dwg test.dwg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...