Message 1 of 26
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Do you have a lisp that convert the Mleader arrow's "angle" to 180 degree?
Solved! Go to Solution.
Do you have a lisp that convert the Mleader arrow's "angle" to 180 degree?
Solved! Go to Solution.
Just thought that I will learn something new.
(vl-load-com) (defun c:MleaderFlat ( / s i c o) (if (setq s (ssget "_:L" '((0 . "MULTILEADER")))) (repeat (setq i (sslength s)) (if (and (setq o (vlax-ename->vla-object (ssname s (setq i (1- i))))) (setq c (vlax-safearray->list (vlax-variant-value (vla-getleaderlinevertices o 0)))) (setq c (apply 'list (mapcar '(lambda (x) (nth x c)) '(0 1 2 3 1 5))))) (vla-SetLeaderLineVertices o 0 (vlax-safearray-fill (vlax-make-safearray vlax-vbDouble '(0 . 5)) c))))) (princ) )
Please can you modify for 45 degree
not asking to create new mleaders, need to edit the existing mleaders
-sorry if i am mistakenly sound- i will try also. . .
@Automohan so please upload a sample dwg , and state constriant to do it .
Better a before and an after .
(vl-load-com) (defun c:Mleader45 ( / s i c o h v) (if (setq s (ssget "_:L" '((0 . "MULTILEADER")))) (repeat (setq i (sslength s)) (if (and (setq o (vlax-ename->vla-object (ssname s (setq i (1- i))))) (setq c (vlax-safearray->list (vlax-variant-value (vla-getleaderlinevertices o 0)))) (setq h (apply 'list (mapcar '(lambda (x) (nth x c)) '(0 1 2)))) (setq v (apply 'list (mapcar '(lambda (x) (nth x c)) '(3 4 5)))) (setq h (polar v (* 1.25 pi) (distance h v)))) (vla-SetLeaderLineVertices o 0 (vlax-safearray-fill (vlax-make-safearray vlax-vbDouble '(0 . 5)) (append h v)))))) (princ) )
Wow! That worked beautifully. Thank you. I appreciate the help very much!
how if we want to make it 30 degrees or 60 degrees , i try change the pi to 0.33 or .66 but that one not accurate. can you help me sir.
How about 0.333333333333333333, does it help? If that's still not enough, add some more, you can go up to 15 digits.
yes sir it can better than before. thank you
i thought we can do with fraction number.
@margono_bersinar wrote:
yes sir it can better than before. thank you
i thought we can do with fraction number.
No, fraction numbers are not supported. You need to use a division. See HERE a list of arithmetical functions that we have available.
This is a function, which takes a decimal degrees angle both positive and negative as an argument. Should be called like (mleader_angle 60) or (mleader_angle -60) etc.
(defun mleader_angle (_angle / mleader_sset index line1 angle_negativity line1_point2)
(vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
(if (not (zerop _angle)) (setq angle_negativity (/ _angle (abs _angle))))
(if (< 360 (abs _angle))
(* angle_negativity (setq _angle (- (abs _angle) (* (fix (/ (abs _angle) 360)) 360))))
)
(if (minusp _angle)
(setq _angle (/ (* (- 360 (abs _angle)) pi) 180))
(setq _angle (/ (* _angle pi) 180))
)
(if (setq mleader_sset (ssget "_:L" '((0 . "multileader"))))
(repeat (setq index (sslength mleader_sset))
(setq line1 (vlax-invoke (setq mleader_object (vlax-ename->vla-object (ssname mleader_sset (setq index (1- index))))) 'getleaderlinevertices 0)
line1_point2 (polar (list (nth 0 line1) (nth 1 line1))
_angle
(distance (list (nth 0 line1) (nth 1 line1)) (list (nth 3 line1) (nth 4 line1)))
)
)
(vlax-invoke mleader_object 'setleaderlinevertices 0 (list (nth 0 line1) (nth 1 line1) (nth 2 line1) (car line1_point2) (cadr line1_point2) (nth 2 line1)))
(if (< (car line1_point2) (car line1))
(progn
(vl-catch-all-apply 'vla-setdoglegdirection (list mleader_object 0 (vlax-3d-point '(-1.0 0.0 0.0))))
(vl-catch-all-apply 'vla-setdoglegdirection (list mleader_object 1 (vlax-3d-point '(-1.0 0.0 0.0))))
)
(progn
(vl-catch-all-apply 'vla-setdoglegdirection (list mleader_object 0 (vlax-3d-point '(+1.0 0.0 0.0))))
(vl-catch-all-apply 'vla-setdoglegdirection (list mleader_object 1 (vlax-3d-point '(+1.0 0.0 0.0))))
)
)
(vlax-invoke mleader_object 'setleaderlinevertices 0 (list (nth 0 line1) (nth 1 line1) (nth 2 line1) (car line1_point2) (cadr line1_point2) (nth 2 line1)))
(princ (strcat "\rMLeaders remain to process: " (itoa index)))
)
)
(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
(princ)
)
updated
how to use this lsp sir?
I copy to my pc can"t use it. can you explain?
as far as i remember
1. type in in command line (load ''saved_code.lsp") <Enter> -> MLEADER_ANGLE
2. type in in command line eg. (mleader_angle 60) <Enter>
3. select mleaders...
when i type "mleader_angle" on command that one "Unknown command "MLEADER_ANGLE". Press F1 for help"
have problem with this lsp?
and can i type command "mleader_angle 60" using space?
it is a function, so it must have parens at both sides "(mleader_angle 60)"
ok sir, it's work. thank you
but no simple one to do like LISP in generally sir?
because we always need to copy & paste if we want to use it. use enter after paste the code can't use twice.
when i update my autocad to 2021, some mleader in my darwing can't use but other can use this LSP and showing like this "Select objects: ; error: Automation Error. Invalid index". any something reson for this one sir?