Jump to content

lisp to explode all mleaders


pioptl

Recommended Posts

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

Link to comment
Share on other sites

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))))
   )
 )

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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)))
   )
 )

Link to comment
Share on other sites

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. =)

Link to comment
Share on other sites

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)
)

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...