Jump to content
daniil

Convert mleader to text

Recommended Posts

daniil

Hi everyone!

 

Want lisp which convert mleader to text (not mtext) and delete arrow or lines if i take explode.

Share this post


Link to post
Share on other sites
pkenewell

Here is the simplest way:

(defun c:ML2TXT (/ en ss)
   (if (and
          ; Mark the last entity in the drawing.
          (setq en (entlast))
          ;; Select the Multileader(s)
          (setq ss (ssget '((0 . "MULTILEADER"))))
       )
       (progn
          (command "._explode" ss);; Explodes the mleader
          ;; loops to get all new entities created after explode.
          (while (setq en (entnext en))
             ;; if a line, polyline or solid, delete it.
             (if (wcmatch (cdr (assoc 0 (entget en))) "*LINE,SOLID")(entdel en))
          )
       ) 
   )
   (princ)
)

 

Share this post


Link to post
Share on other sites
rkmcswain

I just tried it, on a selection set of 9 multileaders. It only operates on one of the 9 in the selection set.

Share this post


Link to post
Share on other sites
pkenewell
20 minutes ago, rkmcswain said:

I just tried it, on a selection set of 9 multileaders. It only operates on one of the 9 in the selection set.

@rkmcswain Thank you - I thought that it would gather all the new entities from the explode command without resetting the last entity. Wrong!

 

Here's is a new solution: Tested on multiple MLEADERS. I had to change it to iterate through the selection set and explode 1 MLEADER at a time, get the new entities and delete them.

(defun c:ML2TXT (/ en ss cnt)
   (if (and
          ; Mark the last entity in the drawing.
          (setq en (entlast))
          ;; Select the Multileader(s)
          (setq ss (ssget '((0 . "MULTILEADER"))))
       )
       (repeat (setq cnt (sslength ss))
          ;; Get 1 MLEADER from the selection set.
          (setq en (ssname ss (setq cnt (1- cnt))))
          ;; Explode the MLEADER
          (command "._explode" en)
          ;; Loop through the newly created entities.
          (while (setq en (entnext en))
             ;; if a line, polyline or solid, delete it.
             (if (wcmatch (cdr (assoc 0 (entget en))) "*LINE,SOLID")(entdel en))
          )
          (setq en (entlast))
       ) 
   )
   (princ)
)

 

Share this post


Link to post
Share on other sites
daniil
On 26/02/2021 at 20:46, pkenewell said:

@rkmcswain Thank you - I thought that it would gather all the new entities from the explode command without resetting the last entity. Wrong!

 

Here's is a new solution: Tested on multiple MLEADERS. I had to change it to iterate through the selection set and explode 1 MLEADER at a time, get the new entities and delete them.


(defun c:ML2TXT (/ en ss cnt)
   (if (and
          ; Mark the last entity in the drawing.
          (setq en (entlast))
          ;; Select the Multileader(s)
          (setq ss (ssget '((0 . "MULTILEADER"))))
       )
       (repeat (setq cnt (sslength ss))
          ;; Get 1 MLEADER from the selection set.
          (setq en (ssname ss (setq cnt (1- cnt))))
          ;; Explode the MLEADER
          (command "._explode" en)
          ;; Loop through the newly created entities.
          (while (setq en (entnext en))
             ;; if a line, polyline or solid, delete it.
             (if (wcmatch (cdr (assoc 0 (entget en))) "*LINE,SOLID")(entdel en))
          )
          (setq en (entlast))
       ) 
   )
   (princ)
)

@pkenewell It is work very strange because this lisp delete polylines too

 

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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