Jump to content

Mleader Angle problem


loudy000

Recommended Posts

attachment.php?attachmentid=59631&cid=1&stc=1

 

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))
)
;                
       

C5.jpg

Link to comment
Share on other sites

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])

Link to comment
Share on other sites

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 by loudy000
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

(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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...