Author Topic: Exploding Mleaders  (Read 2443 times)

0 Members and 1 Guest are viewing this topic.

cmwade77

  • Swamp Rat
  • Posts: 1443
Exploding Mleaders
« on: August 22, 2011, 12:56:37 PM »
For part of a routine that I am working on, I need to temporarily explode mleaders, I have tried both of the following:
Code: [Select]
(setq SS (ssget "_X" (list (cons 0 "MULTILEADER"))))
(cond
(SS
(while (setq Ent (ssname SS 0))
(setq Obj (vlax-ename->vla-object Ent))
(vla-explode Obj)
(ssdel (ssname SS 0) SS)
)
)
)
Code: [Select]
(setq SS (ssget "_X" (list (cons 0 "MULTILEADER"))))
(cond
(SS
(command "._explode" SS "")
)
)

Neither one seems to work correctly, especially with mleaders with blocks attached to them, any ideas?

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Exploding Mleaders
« Reply #1 on: August 22, 2011, 01:00:13 PM »
MLEADERS don't have an explode method. Why do you need to explode them? Perhaps there is a better route.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Exploding Mleaders
« Reply #2 on: August 22, 2011, 01:03:14 PM »
MLEADERS don't have an explode method. Why do you need to explode them? Perhaps there is a better route.
What is annoying is I can manually explode them, but using LISP, it comes up nil when I try to explode them.

Basically, I have everything setup to use Data Extraction, but since it does not support mleaders, I have to explode them first, then undo the exploding.

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Exploding Mleaders
« Reply #3 on: August 22, 2011, 01:47:40 PM »
Nevermind, once again LeeMac and AlanJT have already solved my problem, this time it was posted at CADTutor....http://www.cadtutor.net/forum/showthread.php?49219-lisp-to-explode-all-mleaders&p=335641&viewfull=1#post335641

How do they ever have time to get actual work done with all that they contribute? It amazes me.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Exploding Mleaders
« Reply #4 on: August 22, 2011, 01:55:24 PM »
Perhaps there is a better route.
Yeah, it's call not exploding them.  :-P
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Exploding Mleaders
« Reply #5 on: August 22, 2011, 04:12:57 PM »
Perhaps there is a better route.
Yeah, it's call not exploding them.  :-P

Well DUH  :-P  :-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Exploding Mleaders
« Reply #6 on: August 22, 2011, 05:02:39 PM »
Perhaps there is a better route.
Yeah, it's call not exploding them.  :-P

Well DUH  :-P  :-)
Yeah, like I said, it is a very temporary explosion, here is my code for those that are interested:
Code: [Select]
(defun c:Count (/ *ACAD_DOC* SS PT DWG_Folder)
(vl-load-com)
(setq *ACAD_DOC* (vla-get-ActiveDocument (vlax-get-acad-object)))
;Supporting Functions
(defun count_MLExp2 (/ *error* ss vl ov); Code from AlanJT's adaptation of LeeMac's Code, posted at http://www.cadtutor.net/forum/showthread.php?49219-lisp-to-explode-all-mleaders&p=335641&viewfull=1#post335641
  (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))
(if (setq ss (ssget "_X" (list '(0 . "MULTILEADER") (cons 410 x))))
  (progn (setvar 'ctab x) (command "_.explode" ss ""))
)
  )

  (mapcar 'setvar vl ov)
  (princ)
)
;End of Supporting Functions
(vla-startundomark *ACAD_DOC*)
(vla-startundomark *ACAD_DOC*)
(setq PT (getpoint "\nSelect point for table: "))
(command "._-layer" "_thaw" "*" "_on" "*" "_unlock" "*" "")
(count_MLExp2)
(setq DWG_FOLDER (strcase (getvar "DwgPrefix")))
(vl-cmdf "._-dataextraction" "H:\\0ACAD Support\\AutoCAD\\Customization\\Breen.DXE" PT)
(vl-cmdf "._-wblock" (strcat DWG_Folder "DXE_TEMP.dwg") "" "0,0" (entlast) "")
(vla-endundomark *ACAD_DOC*)
(command "._undo" "1")
(vl-cmdf "._-insert" (strcat "*" DWG_Folder "DXE_TEMP.dwg") "0,0" "1" "0")
(vl-file-delete (strcat DWG_Folder "DXE_TEMP.dwg"))
(vla-endundomark *ACAD_DOC*)
(princ)
)
You would need to setup your own Data Extraction template based on your needs, but it works well, can count anything you need it to, blocks or otherwise, including within Dynamic Arrays.