Text to Multileader Lisp - arrowhead first option auto enable and disable

Text to Multileader Lisp - arrowhead first option auto enable and disable

Helcalian
Enthusiast Enthusiast
2,294 Views
7 Replies
Message 1 of 8

Text to Multileader Lisp - arrowhead first option auto enable and disable

Helcalian
Enthusiast
Enthusiast

I've been using this text to multileader lisp (which I did not author) for a while and it works great. The only issue I have is that you have to have your multileader command set to draw your "leader arrowHead first" where I prefer to content first. Where in this lisp would I add the settings to do this?

 

This one is way beyond my lisp skills so any help would be great.

 

Edit.. sorry for double post, my browser wasn't responding

0 Likes
Accepted solutions (2)
2,295 Views
7 Replies
Replies (7)
Message 2 of 8

ВeekeeCZ
Consultant
Consultant

Launch ACAD, new drawing, start mleader, set it the way you like. Finish mleader. You might save it now, but might not be necessary. Close AutoCAD.

Launch ACAD, new drawing.... all should be fine.

0 Likes
Message 3 of 8

Helcalian
Enthusiast
Enthusiast

Thanks, but I should clarify that I want the Text to Multileader Lisp to do that automatically so that I don't have to manually change my setting before using it. 

0 Likes
Message 4 of 8

Kent1Cooper
Consultant
Consultant

The top of the file suggests it may be by @ronjonp , and if so, they may be able to adjust it more easily than others.

 

@ВeekeeCZ , it's not just a matter of what the current which-first option is, since the routine prompts the User for the arrowhead and landing points before  it starts the MLEADER command -- more of a re-write would be needed.

Kent Cooper, AIA
0 Likes
Message 5 of 8

ВeekeeCZ
Consultant
Consultant
Accepted solution

I did understand... that way it changes the setting in registry, you don't need to change it every time.

 

But you can add "H" to this line

(command "._MLEADER" "_H" pt1 pt2 "")

 

which ... hmmm whatever. Will work.

0 Likes
Message 6 of 8

ronjonp
Mentor
Mentor
Accepted solution

Maybe this ?

(defun c:txt2ml	(/	      allleaders   ent		elst	     ldrpts	  ml
		 objlst	      pt1	   pt2		ss	     txt	  w
		 x	      rjp-getbbwdth		rjp-getpoints
		 rjp-getassociatedleader
		)
  (vl-load-com)
  (defun rjp-getbbwdth (obj / out ll ur)
    (vla-getboundingbox obj 'll 'ur)
    (setq out (mapcar 'vlax-safearray->list (list ll ur)))
    (distance (car out) (list (caadr out) (cadar out)))
  )
  (defun rjp-getpoints (ent)
    (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget ent)))
  )
  (defun rjp-getassociatedleader (ent / pts)
    (if	(and (setq ent (cdadr (member '(102 . "{ACAD_REACTORS") (entget ent))))
	     (setq pts (rjp-getpoints ent))
	)
      (list (car pts) (cadr pts) ent)
    )
  )
  (if (setq ss (ssget '((0 . "*TEXT"))))
    (progn
      (setq txt	   (apply 'strcat
			  (mapcar
			    'cdr
			    (vl-sort
			      (mapcar
				'(lambda (x)
				   (cons (vlax-get x 'insertionpoint) (strcat (vlax-get x 'textstring) " "))
				 )
				(setq
				  objlst (mapcar 'vlax-ename->vla-object
						 (setq elst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
					 )
				)
			      )
			      (function (lambda (y1 y2) (< (cadr (car y2)) (cadr (car y1)))))
			    )
			  )
		   )
	    w	   (car (vl-sort (mapcar 'rjp-getbbwdth objlst) '>))
	    txt	   (substr txt 1 (1- (strlen txt)))
	    ldrpts (car
		     (setq allleaders (reverse (vl-remove 'nil (mapcar 'rjp-getassociatedleader elst))))
		   )
      )
      (mapcar 'vla-delete objlst)
      (cond
	;;leader found for one of the selected text
	((and ldrpts (setq pt1 (car ldrpts)) (setq pt2 (cadr ldrpts)) (setq ent (caddr ldrpts))))
	;;Select a leader
	((and (princ "\nSelect leader to replace [Enter to pick new points]: ")
	      (setq ss (ssget '((0 . "leader"))))
	      (setq ent (ssname ss 0))
	      (setq ldrpts (rjp-getpoints ent))
	      (setq pt1 (car ldrpts))
	      (setq pt2 (cadr ldrpts))
	 )
	)
	;;Just add a new leader
	((and (setq pt1 (getpoint "\nSpecify landing location: "))
	      (setq pt2 (getpoint pt1 "\nSpecify leader arrowhead location: "))
	 )
	)
      )
      (if (and pt1 pt2)
	(progn (command "._MLEADER" "_L" pt1 pt2 "")
	       (setq ml (vlax-ename->vla-object (entlast)))
	       (vla-put-textstring ml txt)
	       (vla-put-textwidth ml w)
	       (if ent
		 (progn	(if (setq txt (cdr (assoc 340 (entget ent))))
			  (entdel txt)
			)
			(entdel ent)
		 )
	       )
	       (mapcar 'entdel (mapcar 'caddr (cdr allleaders)))
	)
      )
    )
  )
  (princ)
)

Changes in green:

ronjonp_0-1602268161171.png

 

0 Likes
Message 7 of 8

ВeekeeCZ
Consultant
Consultant

I did understand...

 

Ok... I did misunderstand, overlooked your preference.

Sorry about that.

0 Likes
Message 8 of 8

Helcalian
Enthusiast
Enthusiast

Thanks folks. Both solutions do make it so that if the Mleader isn't preset to "arrowHead first", the Lisp will still work.

Although the recode done by @ronjonp changes the the justification of the text to right and the leader is always on the right.

 

For my purposes its good enough to have it automatically change the mleader input mode upfront. 

 

Thanks again.

0 Likes