sadhu Posted December 21, 2015 Share Posted December 21, 2015 (edited) I'm using the following code to copy all the blocks in a drawing and then rotate, scale and paste then on the same drawing in an orderly manner (like in a legend). I need to select all the blocks with the attribute "num" even repeating ones. (setq blklst (ssget"_:L" (list (cons 0 "INSERT"))) ; select blocks numblk (sslength blklst) cnt 0 ) (setq pt1 (getpoint "\nSelect insertion point of first block ... ") (setq x1 (car pt1) y1 (cadr pt1)) (while (< cnt numblk) (setq ent (ssname num_blklst cnt)) (setq en2p (entnext ent)) (setq enlist2p (entget en2p)) (while (/= (cdr(assoc 0 enlist2p)) "SEQEND") (cond ((= "num" (cdr (assoc 2 enlist2p))) ; handle blocks with attribute "num" (setq ins_pt_ent (cdr(assoc 10 (entget ent)))) ; get insertion point of block (setq rot_pt_ent (* 0.0174611111(- (cdr(assoc 50 (entget ent)))))) ; rotatation angle of block (command "._copy" ent "" ins_pt_ent pt1 "") ; copy (setq ent (entlast)) (command "_.change" ent "" pt1 rot_pt_ent) ; rotate (command "_.scale" ent "" pt1 2 "") ; scale ));cond (setq en2p(entnext en2p)) ;- Get the next sub-entity (setq enlist2p(entget en2p)) ) (setq pt1 (list x1 (- y1 10))) (setq cnt (+ cnt 1)) );while There are about a 100 blocks and the process is "rather" slow. I can "see" the copy and paste process going on. Any help to make the process faster is welcome. Thank you. Edited December 21, 2015 by sadhu (setq pt1 (list x1 (- y1 10))) ; substituted + Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted December 25, 2015 Share Posted December 25, 2015 (edited) There are about a 100 blocks and the process is "rather" slow. I can "see" the copy and paste process going on. Any help to make the process faster is welcome. Thank you. [EDIT]: Express Tool has similar command MOROCO !!! or change these command call ... (command "._copy" ent "" ins_pt_ent pt1 "") ; copy (setq ent (entlast)) (command "_.change" ent "" pt1 rot_pt_ent) ; rotate (command "_.scale" ent "" pt1 2 "") ; scale ... to activeX suggestion (setq o ([color="blue"]vla-copy[/color] (setq o (vlax-ename->vla-object ent)))) ([color="blue"]vla-put-Rotation[/color] o rot_pt_ent) (apply '[color="blue"]vla-move[/color] (vl-list* o (mapcar 'vlax-3d-point (list ins_pt_ent (trans pt1 1 0))))) (foreach x '([color="blue"]XScaleFactor YScaleFactor[/color]) (vlax-put o x (*(vlax-get o x) 2.)) ) also (setq pt1 (list x1 [color="red"](setq y1[/color] (- y1 10.)[color="red"])[/color])) your COND also can IF ... PROGN command ATTSYNC if you wish [EDIT]: ssget also can add '(66 . 1) , lastly remember to LOCALIZE Edited December 25, 2015 by hanhphuc '(66 .1) & foreach instead of mapcar & moroco Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.