LISP to change MultiLeader Text Orientation

LISP to change MultiLeader Text Orientation

Anonymous
Not applicable
2,003 Views
3 Replies
Message 1 of 4

LISP to change MultiLeader Text Orientation

Anonymous
Not applicable

Hi guys,

I know, I know, at first glance, this topic seems to have been addressed many times before but please keep reading, I'm quite sure mine is a new problem/request:

I use about a dozen of the same multileaders (same text notes) on each and every drawing that I do.  With that in mind, I created a multileader style, used it in assocition with the note/s that go with it and then dragged them straight onto my tool palette so I could just select the one I wanted, click the leader points and bam, pre-typed text inserts attached to the end of the leader.

Only problem is the justifiation.  I cannot change the text justification via the properties, it just reverts back to whatever it was when I stored these pre-made little gems.  I never know which side the standard annotations will originate from so sometimes the text justifies nicely, other times I need to double click the text, select all and hit left/right align to change it to the required.  Using the text editor dialogue really is the only way I can change the justificationon my pre-made multileaders from the tool palette.  The leader style is all set up correctly so please, no hints and tips on that - I suspect my issues largely stem from the leader remembering what the justification was when I saved/dragged it on to the tool palette.

I love not having to type the same notes over and over again but as I say,  double clicking the text, making sure I select it all and then change it via the editor is a stage I'd love a shortcut for.  I still want/need the leaders to point in the direction and place I draw them; no problem there (so MIRROR and commandS like it are not what I'm after).  Would just love a cheeky LISP that I could create a command/tool and then from/with that could flick between left and right justification.

Please sing out if I've confused you.

Thanks everyone.

Brad

0 Likes
2,004 Views
3 Replies
Replies (3)
Message 2 of 4

userlevel6
Advocate
Advocate

sounds like a job for LISP alright... and a fair bit of work to find and modify the correct bit of data.

I'd start by getting two entites to choose from, one the way you want it to be, and one that is waiting for your modification.  Then do an (entget (car (entsel))) on the command line, select one of the objects, and copy the output to a notepad for inspection and comparison.  Repeat for the second entity and compare the data to find what's different.  Note the "flag" number in the (# . data) pairs (like (10 . 0.0 0.0 0.0) for example is an insertion base point.)  The data you want to target and change will probably be found in one of these, and the "flag" is your key to locating and changing the data using LISP. 

That's just the beginning... next step is to make LISP use the "entmod" and "entupd" functions to make the changes... hopefully someone has a quicker answer. 😉 

0 Likes
Message 3 of 4

ronjonp
Advisor
Advisor

Post a sample drawing of what you're working with. It sounds like your style is buggered or the mtext is hard coded internally.

2021-02-04_15-31-47.gif

Here's a quick snippet to toggle left and right.

 

 

(defun c:foo (/ o s)
  (if (setq s (ssget ":L" '((0 . "MULTILEADER"))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (vla-put-textjustify
	(setq o (vlax-ename->vla-object e))
	(if (= 1 (vla-get-textjustify o))
	  3
	  1
	)
      )
    )
  )
  (princ)
)

 

 

 

Here's one that checks the direction of the first leader and applies the correct justification. Let me add that this method can be fooled depending on how the leader is oriented.

 

 

(defun c:foo (/ o s v)
  (if (setq s (ssget ":L" '((0 . "MULTILEADER"))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (setq v (vlax-invoke (setq o (vlax-ename->vla-object e)) 'getleaderlinevertices 0))
      (vla-put-textjustify
	o
	(if (> (car v) (cadddr v))
	  3
	  1
	)
      )
    )
  )
  (princ)
)

 

 

 

 

0 Likes
Message 4 of 4

ВeekeeCZ
Consultant
Consultant

Also would be beneficial if you post some screen capture as well.

0 Likes