pioptl Posted June 16, 2010 Share Posted June 16, 2010 Anyone know where I can find a lisp to explode ALL mleaders in a drawing (both in model and all layouts)? I often have to export C3d drawings & save down to older versions for clients. A lisp that would explode ALL of them at once would help streamline the steps. Thanks, Kevin Quote Link to comment Share on other sites More sharing options...
Freerefill Posted June 16, 2010 Share Posted June 16, 2010 Quick and dirty, but it should do the job. (defun c:x_mlead( / listy) (vl-load-com) (vlax-for var (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (setq listy (cons (cons (vla-get-TabOrder var) (vla-get-Name var)) listy))) (setq listy (mapcar 'cdr (vl-sort listy '(lambda (x y) (< (car x) (car y)))))) (foreach fv listy (setvar "ctab" fv) (vl-cmdf "explode" (ssget "X" (list '(0 . "MULTILEADER") (cons 410 fv)))) ) ) Quote Link to comment Share on other sites More sharing options...
pioptl Posted June 16, 2010 Author Share Posted June 16, 2010 Thanks Freerefill, but didn't work, here is waht I get when run: APPLOAD Command: x_mlead explode Select object: Command: Regenerating layout. Application ERROR: Invalid type sent as command input Regenerating layout. Regenerating model. Application ERROR: Invalid type sent as command input Regenerating layout. Regenerating model. explode Select object: Command: Regenerating layout. Regenerating model. explode Select object: Command: Regenerating layout. Regenerating model. explode Select object: Command: Regenerating layout. Regenerating model. explode Select object: Command: Regenerating layout. Regenerating model. explode Select object: Command: Regenerating layout. Regenerating model. explode Select object: Command: Regenerating layout. Regenerating model. Application ERROR: Invalid type sent as command input nil Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 16, 2010 Share Posted June 16, 2010 I would code it this way: (defun c:MLExp ( / *error* ss vl ov ) (defun *error* ( msg ) (and ov (mapcar 'setvar vl ov)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) (setq vl '("CTAB" "CMDECHO" "QAFLAGS") ov (mapcar 'getvar vl)) (mapcar 'setvar (cdr vl) '(0 5)) (foreach x (cons "Model" (layoutlist)) (setvar 'ctab x) (if (setq ss (ssget "_X" (list '(0 . "MULTILEADER") (cons 410 x)))) (command "_.explode" ss "") ) ) (mapcar 'setvar vl ov) (princ) ) Quote Link to comment Share on other sites More sharing options...
Freerefill Posted June 16, 2010 Share Posted June 16, 2010 Yeah, my bad. Should have snuck in a check to see if there were any to explode in the first place. This should take care of it: (defun c:x_mlead( / listy ss) (vl-load-com) (vlax-for var (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (setq listy (cons (cons (vla-get-TabOrder var) (vla-get-Name var)) listy))) (setq listy (mapcar 'cdr (vl-sort listy '(lambda (x y) (< (car x) (car y)))))) (foreach fv listy (setq ss (ssget "X" (list '(0 . "MULTILEADER") (cons 410 fv)))) (if ss (progn (setvar "ctab" fv) (vl-cmdf "explode" ss))) ) ) Quote Link to comment Share on other sites More sharing options...
pioptl Posted June 17, 2010 Author Share Posted June 17, 2010 Thanks Lee, works just fine. =) You'd think that Autocad would automaticly do this when saving down to 2000 since 2000 doesnt support multileaders. But that would just make sense wouldn't it. =) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 17, 2010 Share Posted June 17, 2010 You're quite welcome Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 18, 2010 Share Posted June 18, 2010 Could make one change and avoid switching to layouts that do not include MLeaders... (defun c:MLExp2 (/ *error* ss vl ov) (defun *error* (msg) (and ov (mapcar 'setvar vl ov)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **")) ) (princ) ) (setq vl '("CTAB" "CMDECHO" "QAFLAGS") ov (mapcar 'getvar vl) ) (mapcar 'setvar (cdr vl) '(0 5)) (foreach x (cons "Model" (layoutlist)) [color=Red] (if (setq ss (ssget "_X" (list '(0 . "MULTILEADER") (cons 410 x)))) (progn (setvar 'ctab x) (command "_.explode" ss "")) )[/color] ) (mapcar 'setvar vl ov) (princ) ) 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.