heathera Posted March 23, 2012 Posted March 23, 2012 Hey guys I wonder if someone could write me a quick lisp file to speed up my work load. i need it to do the following. 1. explode all the blocks in the drawing till there are no more. (i already have this lisp by itself) 2. Select everything in the drawing and place all objects on bylayer (colour, line type etc) 3. select all objects on layer 0 and place on a new layer (layer0) i have about 200 drawings i need to do this to so would be very great full to anyone who could help Quote
pBe Posted March 23, 2012 Posted March 23, 2012 A lisp for all three? You mentioned you have a routine for item 1. Setbylayer will take care of item 2. That leaves us with item 3. (defun c:DoAll (/ ln ss i e) (setq ln "YourLayer") (setq ss (ssget "_X" '((8 . "0")))) (repeat (setq i (sslength ss)) (entmod (subst (cons 8 ln) (assoc 8 (setq e (entget (ssname ss (setq i (1- i)))))) e)) )(princ) ) Quote
heathera Posted March 23, 2012 Author Posted March 23, 2012 Thanks for this could i some how combine all three to make one long lisp? here is the one i use for exploding blocks (defun c:exall(/ bSet) (setvar "qaflags" 1) (while(setq bSet(ssget "_X" '((0 . "INSERT")))) (command "_.explode" bSet "") ); end while (repeat 3(command "-purge" "all" "" "n")) (setvar "qaflags" 0) (princ) ); end of c:exall Quote
pBe Posted March 23, 2012 Posted March 23, 2012 Thanks for this could i some how combine all three to make one long lisp? here is the one i use for exploding blocks I guess it can be done. Would this be limited to Model Space? or does it include objects at Layout tabs? Quote
heathera Posted March 23, 2012 Author Posted March 23, 2012 I guess it can be done. Would this be limited to Model Space? or does it include objects at Layout tabs? Just model space Quote
heathera Posted March 23, 2012 Author Posted March 23, 2012 Last Q:XREF? No xrefs in the drawing at all. Quote
pBe Posted March 23, 2012 Posted March 23, 2012 (edited) Okay A bunch of code cobbled together (defun c:DoAll (/ ln aDoc blknme bSetss i e) (vl-load-com) (setq ln "YourLayer") (setq aDoc (vla-get-activedocument (vlax-get-acad-object))) (while (setq a (tblnext "BLOCK" (null a))) (setq blknme (vla-item (vla-get-blocks aDoc) (cdr (assoc 2 a)))) (vla-put-Explodable blknme :vlax-true) (vlax-for itm blknme (vla-put-color itm acByLayer) (vla-put-linetype itm "ByLayer") (vla-put-lineweight itm -1))) (while (setq bSet (ssget "_X" '((0 . "INSERT") (410 . "MODEL")))) (command "_.explode" bSet) ) (if (setq ss (ssget "_X" '((8 . "0")))) (repeat (setq i (sslength ss)) (entmod (subst (cons 8 ln) (assoc 8 (setq e (entget (ssname ss (setq i (1- i)))))) e)) ) ) (repeat 4 (vla-purgeall aDoc) ) (princ) ) EDIT: Modified to account for UnExplodable Block entity Edited March 23, 2012 by pBe Quote
heathera Posted March 23, 2012 Author Posted March 23, 2012 Okay A bunch of code cobbled together (defun c:DoAll (/ ln aDoc blknme bSetss i e) (vl-load-com) (setq ln "YourLayer") (setq aDoc (vla-get-activedocument (vlax-get-acad-object))) (while (setq a (tblnext "BLOCK" (null a))) (setq blknme (vla-item (vla-get-blocks aDoc) (cdr (assoc 2 a)))) (vla-put-Explodable blknme :vlax-true) (vlax-for itm blknme (vla-put-color itm acByLayer) (vla-put-linetype itm "ByLayer") (vla-put-lineweight itm -1))) (while (setq bSet (ssget "_X" '((0 . "INSERT") (410 . "MODEL")))) (command "_.explode" bSet) ) (if (setq ss (ssget "_X" '((8 . "0")))) (repeat (setq i (sslength ss)) (entmod (subst (cons 8 ln) (assoc 8 (setq e (entget (ssname ss (setq i (1- i)))))) e)) ) ) (repeat 4 (vla-purgeall aDoc) ) (princ) ) EDIT: Modified to account for UnExplodable Block entity Thank you but it seems to get stuck on Command: _.explode Select object: Command: _.explode Select object: Command: _.explode Select object: Command: _.explode it just keeps repeating until i cancel , any ideas? Thanks for helping me out. Quote
pBe Posted March 23, 2012 Posted March 23, 2012 Thank you but it seems to get stuck on Command: _.explode Select object: Command: _.explode Select object: Command: _.explode Select object: Command: _.explode it just keeps repeating until i cancel , any ideas? Thanks for helping me out. Is not an error, that is a result of nested blocks found (ssget) inside the while loop. [copied from you c::exall routine] Command: cmdecho Enter new value for CMDECHO : 0 Quote
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.