loudy000 Posted October 31, 2016 Share Posted October 31, 2016 I've been working and trying to understand this code, with the help of Tedg and Lee Mac I'm able to achieve my desired result however i'm struggling to figure out why when i insert the additional code which Lee has provided in my previous post the angle on the other side is not working properly. Without the code (highlighted) the routine is working properly (considering that the "set landing distance" is unchecked but i need those code to uncheck and check after the command. I need some help where the code went wrong? Im not really good lisp, i just stitch them from various codes so im not really sure if that's the proper way to do it. Thank you in advance cheers! (defun c:mm (/ nm p1 p2 ateblk p3) (setq l_ang 90) (setq l_ang1 -270) (defun MLeaderstyle ( sty flg / dic ) (and (setq dic (dictsearch (namedobjdict) "acad_mleaderstyle")) (setq dic (dictsearch (cdr (assoc -1 dic)) sty)) (entmod (subst (cons 43 ((if flg + -) (abs (cdr (assoc 43 dic))))) (assoc 43 dic) dic)) ) ) (MLeaderLandingDistance (getvar 'cmleaderstyle) nil) (command "cmdecho" "0") (setq osm (getvar "osmode")) (setq ort (getvar "orthomode")); (command "osmode" "15359") (setq p1 (getpoint "\nPick origin point:)")) (command "osmode" "0") (command "orthomode" "0") (setq p2 (getpoint "\nPick target" p1)) (princ) (if (< (car p1) (car p2)) (progn (if (< (cadr p1) (cadr p2)) (setq p3d (- (cadr p1) (cadr p2))) ) (if (< (cadr p2) (cadr p1)) (setq p3d (- (cadr p2) (cadr p1))) ) (if (< (cadr p2) (cadr p1)) (progn (setq p3 (polar p2 (+ 0.0 (dtr (- l_ang))) (* p3d 1.00))) ) ) (if (< (cadr p1) (cadr p2)) (progn (setq p3 (polar p2 (+ 0.0 (dtr l_ang)) (* p3d 1.00))) ) ) ) ) (if (< (car p2) (car p1)) (progn (if (< (cadr p1) (cadr p2)) (setq p3d (- (cadr p1) (cadr p2))) ) (if (< (cadr p2) (cadr p1)) (setq p3d (- (cadr p2) (cadr p1))) ) (if (< (cadr p2) (cadr p1)) (progn (setq p3 (polar p2 (+ 0.0 (dtr (- l_ang1))) (* p3d 1.00))) ) ) (if (< (cadr p1) (cadr p2)) (progn (setq p3 (polar p2 (+ 0.0 (dtr l_ang1)) (* p3d 1.00))) ) ) ) ) (command "_mleader" "L" "H" "o" "m" "2" "x" p2 p3 p1 "XX-XX") (MLeaderLandingDistance (getvar 'cmleaderstyle) t) (command "osmode" osm) (command "orthomode" ort) ) ; (defun dtr (a) (* pi (/ a 180.0)) ) ; Quote Link to comment Share on other sites More sharing options...
loudy000 Posted October 31, 2016 Author Share Posted October 31, 2016 I don't know how to delete it was posted 3x sorry Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 31, 2016 Share Posted October 31, 2016 Here is a relatively basic example to set you in the right direction: ([color=BLUE]defun[/color] c:mlexample ( [color=BLUE]/[/color] mld pt1 pt2 tmp ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] pt1 ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify point for text: "[/color])) ([color=BLUE]setq[/color] pt2 ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify point for arrowhead: "[/color] pt1)) ) ([color=BLUE]progn[/color] ([color=BLUE]setq[/color] mld ([color=BLUE]vlax-invoke[/color] ([color=BLUE]vlax-get-property[/color] ([color=BLUE]vla-get-activedocument[/color] ([color=BLUE]vlax-get-acad-object[/color])) ([color=BLUE]if[/color] ([color=BLUE]=[/color] 1 ([color=BLUE]getvar[/color] 'cvport)) 'paperspace 'modelspace) ) 'addmleader ([color=BLUE]append[/color] ([color=BLUE]trans[/color] pt2 1 0) ([color=BLUE]trans[/color] ([color=BLUE]list[/color] ([color=BLUE]car[/color] pt2) ([color=BLUE]cadr[/color] pt1) ([color=BLUE]caddr[/color] pt1)) 1 0)) 0 ) ) ([color=BLUE]vla-put-textstring[/color] mld [color=MAROON]"XX-XX"[/color]) ([color=BLUE]vla-put-textrotation[/color] mld 0.0) ([color=BLUE]vla-put-dogleglength[/color] mld ([color=BLUE]abs[/color] ([color=BLUE]-[/color] ([color=BLUE]car[/color] pt1) ([color=BLUE]car[/color] pt2)))) ([color=BLUE]if[/color] ([color=BLUE]<=[/color] ([color=BLUE]car[/color] pt1) ([color=BLUE]car[/color] pt2)) ([color=BLUE]progn[/color] ([color=BLUE]setq[/color] tmp ([color=BLUE]vla-getleaderlinevertices[/color] mld 0)) ([color=BLUE]vla-setdoglegdirection[/color] mld 0 ([color=BLUE]vlax-3D-point[/color] ([color=BLUE]trans[/color] '(-1.0 0.0) 1 0 [color=BLUE]t[/color]))) ([color=BLUE]vla-put-textrightattachmenttype[/color] mld [color=BLUE]acattachmentmiddle[/color]) ([color=BLUE]vla-setleaderlinevertices[/color] mld 0 tmp) ) ) ) ) ([color=BLUE]princ[/color]) ) ([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color]) Quote Link to comment Share on other sites More sharing options...
loudy000 Posted November 1, 2016 Author Share Posted November 1, 2016 (edited) Here is a relatively basic example to set you in the right direction: ([color=BLUE]defun[/color] c:mlexample ( [color=BLUE]/[/color] mld pt1 pt2 tmp ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] pt1 ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify point for text: "[/color])) ([color=BLUE]setq[/color] pt2 ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify point for arrowhead: "[/color] pt1)) ) ([color=BLUE]progn[/color] ([color=BLUE]setq[/color] mld ([color=BLUE]vlax-invoke[/color] ([color=BLUE]vlax-get-property[/color] ([color=BLUE]vla-get-activedocument[/color] ([color=BLUE]vlax-get-acad-object[/color])) ([color=BLUE]if[/color] ([color=BLUE]=[/color] 1 ([color=BLUE]getvar[/color] 'cvport)) 'paperspace 'modelspace) ) 'addmleader ([color=BLUE]append[/color] ([color=BLUE]trans[/color] pt2 1 0) ([color=BLUE]trans[/color] ([color=BLUE]list[/color] ([color=BLUE]car[/color] pt2) ([color=BLUE]cadr[/color] pt1) ([color=BLUE]caddr[/color] pt1)) 1 0)) 0 ) ) ([color=BLUE]vla-put-textstring[/color] mld [color=MAROON]"XX-XX"[/color]) ([color=BLUE]vla-put-textrotation[/color] mld 0.0) ([color=BLUE]vla-put-dogleglength[/color] mld ([color=BLUE]abs[/color] ([color=BLUE]-[/color] ([color=BLUE]car[/color] pt1) ([color=BLUE]car[/color] pt2)))) ([color=BLUE]if[/color] ([color=BLUE]<=[/color] ([color=BLUE]car[/color] pt1) ([color=BLUE]car[/color] pt2)) ([color=BLUE]progn[/color] ([color=BLUE]setq[/color] tmp ([color=BLUE]vla-getleaderlinevertices[/color] mld 0)) ([color=BLUE]vla-setdoglegdirection[/color] mld 0 ([color=BLUE]vlax-3D-point[/color] ([color=BLUE]trans[/color] '(-1.0 0.0) 1 0 [color=BLUE]t[/color]))) ([color=BLUE]vla-put-textrightattachmenttype[/color] mld [color=BLUE]acattachmentmiddle[/color]) ([color=BLUE]vla-setleaderlinevertices[/color] mld 0 tmp) ) ) ) ) ([color=BLUE]princ[/color]) ) ([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color]) Thank you very much Lee. Another great code. Always the best Edited November 1, 2016 by loudy000 Quote Link to comment Share on other sites More sharing options...
Grrr Posted November 1, 2016 Share Posted November 1, 2016 Nice code Lee, as always. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 1, 2016 Share Posted November 1, 2016 Thank you very much Lee. Another great code. Always the best You're welcome! Nice code Lee, as always. Thanks Quote Link to comment Share on other sites More sharing options...
loudy000 Posted November 2, 2016 Author Share Posted November 2, 2016 You're welcome! Thanks hi Lee, thanks again for the code I just noticed that I cannot control in when im in model space but in paperspace it's working great. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 2, 2016 Share Posted November 2, 2016 hi Lee, thanks again for the code I just noticed that I cannot control in when im in model space but in paperspace it's working great. The program is working fine for me in Modelspace - can you provide an example? Quote Link to comment Share on other sites More sharing options...
Grrr Posted November 2, 2016 Share Posted November 2, 2016 The program is working fine for me in Modelspace - can you provide an example? (1+) I tried it also. Quote Link to comment Share on other sites More sharing options...
loudy000 Posted November 3, 2016 Author Share Posted November 3, 2016 The program is working fine for me in Modelspace - can you provide an example? Hi Lee this is the result when im in modelspace Quote Link to comment Share on other sites More sharing options...
loudy000 Posted November 3, 2016 Author Share Posted November 3, 2016 (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace) (if (= 2 (getvar 'cvport)) 'paperspace 'modelspace) "2" value is working although im not really sure what that means i just try changing it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.