Message 1 of 19

Not applicable
09-29-2019
10:19 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
My code takes a given mleader, and snaps it to make the leader line at a 90 degree angle, based on what's closest. Could this be scaled into something that works for all modelspace mleaders? What I have been attempting has been to have it take the rotation of the mleader in modelspace to translate the points. I thought this would be quicker than cycling through each viewport, knowing that all mleaders will be at 90 degrees within their respective viewports. I was mainly just struggling with the maths for the rotational transformations, and I'm not very good with using mapcar/foreach
(vl-load-com) (defun C:MAL (/ ent vlent out vlout bp lp vlp newlp ) (while (setq ent (car (entsel))) (setq vlent (vlax-ename->vla-object ent)) (setq vlout (vla-getleaderlinevertices vlent 0)) (princ (vlax-safearray-get-dim (vlax-variant-value vlout))) (setq out (vlax-safearray->list (vlax-variant-value vlout))) (setq bp (list (nth 0 out) (nth 1 out) (nth 2 out))) (setq lp (list (nth 3 out) (nth 4 out) (nth 5 out))) (setq bp (trans bp 0 2)) (setq lp (trans lp 0 2)) (if (>= (abs (- (car bp) (car lp))) (abs (- (cadr bp) (cadr lp)))) (progn (setq newlp (list (car lp) (cadr bp) 0.0)) (setq newlp (trans newlp 2 0)) (setq vlp (vlax-make-safearray 5 '(0 . 5))) (vlax-safearray-fill vlp (append (trans bp 2 0) newlp)) (vla-setleaderlinevertices vlent 0 vlp) ) (progn (setq newlp (list (car bp) (cadr lp) 0.0)) (setq newlp (trans newlp 2 0)) (setq vlp (vlax-make-safearray 5 '(0 . 5))) (vlax-safearray-fill vlp (append (trans bp 2 0) newlp)) (vla-setleaderlinevertices vlent 0 vlp) ) ) ) (princ) )
Solved! Go to Solution.