- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm working on a function that extracts information from an MLeader (text box width, text contents, and location), creates a new MLeader with this information, and deletes the original MLeader.
The routine works in general, except there's an issue with the landing location of the newly-created MLeader. I'll describe the issue with images:
1) Original MLeader object (Note: landing attachment location is set to "Middle of Text", consistent with graphical display)
---
2) Running the function on this MLeader deletes the original and creates a new one, shown below. Note: the new MLeader displays as if attachment was "Middle of Top Line" yet properties show "Middle" still.
---
3) Turns out this new MLeader just needs to be "refreshed" to get the attachment location to snap back to the middle of text as the properties show. To refresh it, all I have to do is go into the Text Editor (double click the text - image a), and without making any change, exit the Text Editor (click anywhere). After doing this, MLeader "refreshes" and landing attachment shows correctly (image b).
a)
b)
---
The issue is that manually refreshing leaders like this is very time consuming. How can I edit my LISP function to refresh the MLeader? I have tried (entupd newmleader) but it didn't work. Would appreciate any input or direction. See below for my code:
(defun c:examplefunction () ; name function
(setq mleadertemp (entsel "\nPick MLeader")) ; pick MLeader
(setq mleaderID (car mleadertemp)) ; entsel returns two values when selecting mleader, this extracts only first val
(setq mleader (entget mleaderID)) ; association list for selected mleader
(setq text (cdr(assoc 304 mleader))) ; retrieves text content of mleader
(setq width (cdr(assoc 43 mleader))) ; retrieves text width of mleader
(setq c -1) ; set counter to -1
(setq len (length mleader)) ; len is length of mleader
(setq num 1) ; association list element
(while
(and
(< c (- len 1))
(/= num 302)
)
(setq c (+ c 1))
(setq element (nth c mleader))
(setq num (car element))
) ; c contains the nth element with LEADER
(repeat c ; Removes items from mleader assoc list
(setq mleader (vl-remove (nth 0 mleader) mleader)) ; Removes items to expose leader location
)
(setq pt1 (cdr(assoc 10 mleader))) ; retrieves coords of landing location
(setq m 6) ; Removes items from mleader assoc list
(repeat m
(setq mleader (vl-remove (nth 0 mleader) mleader)) ; Removes items to expose arrowhead
)
(setq pt2 (cdr(assoc 10 mleader))) ; retrieves coords of arrowhead
(command "MLEADER" pt2 pt1 text)
(command "_.erase" mleadertemp "") ; erase leader picked
(setq ent (entlast)) ; Set entity to newly created MLeader
(setq newmleader (entget ent)) ; newly created mleader to modify width
(entmod ; modify width of new mleader
(setq newmleader (subst (cons 43 width) (assoc 43 newmleader) newmleader))
)
(princ)
) ; defun
Solved! Go to Solution.