Author Topic: MLEADERS  (Read 2131 times)

0 Members and 1 Guest are viewing this topic.

gwong

  • Guest
MLEADERS
« on: August 04, 2008, 11:50:28 AM »
I want to make the following Lisp file underline the top line using lisp code is this possible? 

MLEADER Code

(defun C:crd ()
(setq pntlist (getpoint "\n Pick Point: "))
(setq px (rtos (car pntlist))
py (rtos(cadr pntlist))

)
(setq coordstr (strcat "N " py "\nE " px))
(Setq P2 (Getpoint pntlist "Pick Leader End:"))
(If(<=(Car P2)(Car pntlist))
(Setq B(* -0.1 (getvar "dimscale")))
(Setq B (* 0.1 (getvar "dimscale")))
)
(Setq P3 (List (+ (Car P2) B) (Cadr P2)))
(Command "mleader" pntlist p3 "y" coordstr "")
(princ)
)

ronjonp

  • Needs a day job
  • Posts: 7531
Re: MLEADERS
« Reply #1 on: August 04, 2008, 12:17:36 PM »
Replace this line:

(setq coordstr (strcat "N " py "\nE " px))

With this:

(setq coordstr (strcat "{\\L N " py "}\nE " px))

*modified...had an extra "N"
« Last Edit: August 04, 2008, 12:21:07 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

gwong

  • Guest
Re: MLEADERS
« Reply #2 on: August 04, 2008, 12:45:56 PM »
Could you make the MLEADER use the property Under Top Line?

ronjonp

  • Needs a day job
  • Posts: 7531
Re: MLEADERS
« Reply #3 on: August 04, 2008, 03:00:32 PM »
Something like this?

Code: [Select]
(defun c:crd (/ b coordstr p2 p3 pntlist px py ent)
  (setq pntlist (getpoint "\n Pick Point: "))
  (setq px (rtos (car pntlist))
py (rtos (cadr pntlist))
  )
  (setq coordstr (strcat "{\\LN " py "}\nE " px))
  (Setq P2 (Getpoint pntlist "Pick Leader End:"))
  (If (<= (Car P2) (Car pntlist))
    (Setq B (* -0.1 (getvar "dimscale")))
    (Setq B (* 0.1 (getvar "dimscale")))
  )
  (Setq P3 (List (+ (Car P2) B) (Cadr P2)))
  (Command "_.mleader" pntlist p3 coordstr)
  (setq ent (vlax-ename->vla-object (entlast)))
  (vla-put-TextRightAttachmentType ent 3)
  (vla-put-TextLeftAttachmentType ent 3)
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

gwong

  • Guest
Re: MLEADERS
« Reply #4 on: August 04, 2008, 04:58:50 PM »
I looks like what I want but for some reason when I run the lisp it doesn't work properly and errors out.  It runs through the whole lisp but when it gets to the property overrides that I want it quits.

Thanks

ronjonp

  • Needs a day job
  • Posts: 7531
Re: MLEADERS
« Reply #5 on: August 04, 2008, 05:11:21 PM »
Try adding (vl-load-com) to the beginning of the routine.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

gwong

  • Guest
Re: MLEADERS
« Reply #6 on: August 04, 2008, 05:23:29 PM »
That worked thanks for the help it is very much appreciated.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: MLEADERS
« Reply #7 on: August 04, 2008, 05:42:00 PM »
Not a problem :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

gwong

  • Guest
Re: MLEADERS
« Reply #8 on: August 04, 2008, 05:57:00 PM »
Would this be the code if I wanted the Leader a different Color?

(vla-put-LeaderLineColor ent "1")

ronjonp

  • Needs a day job
  • Posts: 7531
Re: MLEADERS
« Reply #9 on: August 05, 2008, 11:35:31 AM »
Using Mike's function here: http://www.theswamp.org/index.php?topic=22661.msg273227#msg273227

This should do it:

(vla-put-LeaderLineColor ent (maketcolor 1))

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC