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

Need to put a new block over old block using propooerties

3 REPLIES 3
Reply
Message 1 of 4
richie_hodgson
451 Views, 3 Replies

Need to put a new block over old block using propooerties

Hi, I would like to select all instances of a block, and put a new block on top of them using the same properties (insertion, rotation) but am unsure how to do this

Richie
3 REPLIES 3
Message 2 of 4
mracad
in reply to: richie_hodgson

(defun C:REPBLK ()
(setq Old_blk "Triangle")
(setq New_blk "Square")
(setq KK 0)
(if (setq SS (ssget "X" (list (cons 0 "INSERT") (cons 2 Old_blk))))
(while (< KK (sslength SS))
(setq EG (entget (ssname SS KK)))
(setq P0 (cdr (assoc 10 EG))) ;insertion point
(setq RR (cdr (assoc 50 EG))) ;rotation in radian
(setq RA (/ (* RR 180) pi)) ;rotation in degrees
(setq SX (cdr (assoc 41 EG))) ;x scale
(setq SY (cdr (assoc 42 EG))) ;y scale
(setq SZ (cdr (assoc 43 EG))) ;z scale
(setq LN (cdr (assoc 8 EG))) ;layer
(command "Insert" New_blk P0 "XYZ" SX SY SZ RA)
(while (/= (getvar "CMDACTIVE") 0);set all attributes to blank
(command "")
)
(entdel (cdr (assoc -1 EG))) ;delete old block
(setq KK (1+ KK))
)
)
(princ)
)
;doesn't set layer, get attributes, etc.
Alan
Message 3 of 4
richie_hodgson
in reply to: mracad

That was nearly there, I have removed the delete original block line as I wanted the original to remain, had a little bit of tinklering with the rotation to work with our set up, 0 degrees = north and clockwise rotation. Now I can have a fiddle to get the blocks into the correct layer. Thanks heeps.

Richie
Message 4 of 4
3wood
in reply to: richie_hodgson

You can also try this without using any lisp routine.

1. Edit existing block A with Block Editor. Save the block definition as Block B

2. Edit existing block A with Block Editor again. Insert Block B and remove all other objects.

3. Insert Block C (the one you want put on top of Block A)

4. Close block editor, select all instances of Block A (use "Select Similar") and EXPLODE they all.

5. Purge Block A. Rename Block B to Block A.

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

Post to forums  

Autodesk Design & Make Report

”Boost