Author Topic: [LISP] Can we add/remove leader to mleader with lisp ?  (Read 2293 times)

0 Members and 1 Guest are viewing this topic.

kruuger

  • Swamp Rat
  • Posts: 619
[LISP] Can we add/remove leader to mleader with lisp ?
« on: September 30, 2013, 03:32:20 AM »
hello,

can we add or remove additional leader from mleader with lisp?
i know that we can right click on object and then add/remove but it is time consuming.

thanks
kruuger



kojacek

  • Mosquito
  • Posts: 14
Re: [LISP] Can we add/remove leader to mleader with lisp ?
« Reply #1 on: September 30, 2013, 05:03:32 AM »
hello,
can we add or remove additional leader from mleader with lisp?
i know that we can right click on object and then add/remove but it is time consuming.
Hi kruuger
You can adds a new leader line to Mleader:
Code - Auto/Visual Lisp: [Select]
  1. (jk:ACX_AddMLeaderPointex (car (entsel "\nMleader: ")) (getpoint "\nPoint: "))
used this code:
Code - Auto/Visual Lisp: [Select]
  1. (defun jk:ACX_AddMLeaderPointEx (en pt / d vo pts)
  2.   (setq d (entget en)
  3.         vo (vlax-ename->vla-object en)
  4.   )
  5.   (setq pts
  6.     (apply
  7.       (quote append)
  8.       (mapcar
  9.         (function
  10.           (lambda (%)
  11.             (list (car %)(cadr %)(caddr %))
  12.           )
  13.         )
  14.         (mapcar
  15.           (function
  16.             (lambda (%)
  17.               (trans % 1 (trans '(0 0 1) 1 0 T))
  18.             )
  19.           )
  20.           (list Pt (cdr (assoc 10 d)))
  21.         )
  22.       )
  23.     )
  24.   )
  25.   (vla-AddLeaderLineEx vo
  26.     (vlax-make-variant
  27.         (vlax-make-safearray vlax-vbdouble (cons 0 (1- (length Pts))))
  28.         Pts
  29.       )
  30.     )
  31.   )
  32. )

regards
kojacek

kruuger

  • Swamp Rat
  • Posts: 619
Re: [LISP] Can we add/remove leader to mleader with lisp ?
« Reply #2 on: September 30, 2013, 05:10:59 AM »
great thanks :)

when we add new leader text change location - see picture.
now i got something to play. i will try to fix this.

kruuger


kruuger

  • Swamp Rat
  • Posts: 619
Re: [LISP] Can we add/remove leader to mleader with lisp ?
« Reply #3 on: October 03, 2013, 04:00:44 PM »
Code: [Select]
(defun c:ADDL (/ ob)
  (if (setq ob (entsel "\nPlease select MULTILEADER: "))
    (if (= (cdr (assoc 0 (entget (car ob)))) "MULTILEADER")
      (progn
        (command "._mleaderedit" (car ob) pause)
      )
      (princ "\n** Object selected was not a multileader. ** ")
    )
    (princ "\n** Nothing selected ** ")
  )
  (princ)
)
(defun c:REML (/ ob)
  (if (setq ob (entsel "\nPlease select MULTILEADER: "))
    (if (= (cdr (assoc 0 (entget (car ob)))) "MULTILEADER")
      (progn
        (command "._mleaderedit" (car ob) "_remove" pause)
      )
      (princ "\n** Object selected was not a multileader. ** ")
    )
    (princ "\n** Nothing selected ** ")
  )
  (princ)
)
k.

Krushert

  • Seagull
  • Posts: 13651
  • FREE BEER Tomorrow!!
Re: [LISP] Can we add/remove leader to mleader with lisp ?
« Reply #4 on: October 03, 2013, 06:51:35 PM »
^^
Very sweet.  Thanks!
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here for camaraderie

ronjonp

  • Needs a day job
  • Posts: 7307
Re: [LISP] Can we add/remove leader to mleader with lisp ?
« Reply #5 on: October 04, 2013, 09:45:29 AM »
You could also combine the two routines into one like so :).
Code: [Select]
(defun c:arml (/ ob)
  (or *mleaderoptionglobal* (setq *mleaderoptionglobal* "Add"))
  (initget 0 "Add Remove")
  (setq *mleaderoptionglobal*
(cond ((getkword (strcat "\n[Add/Remove] <" *mleaderoptionglobal* ">: ")))
       (*mleaderoptionglobal*)
)
  )
  (if (setq ob (car (entsel "\nPlease select MULTILEADER: ")))
    (if (= (cdr (assoc 0 (entget ob))) "MULTILEADER")
      (if (= *mleaderoptionglobal* "Add")
(command "._mleaderedit" ob pause)
(command "._mleaderedit" ob "_remove" pause)
      )
      (princ "\n** Object selected was not a multileader. ** ")
    )
    (princ "\n** Nothing selected ** ")
  )
  (princ)
)

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

kruuger

  • Swamp Rat
  • Posts: 619
Re: [LISP] Can we add/remove leader to mleader with lisp ?
« Reply #6 on: October 04, 2013, 10:57:36 AM »
You could also combine the two routines into one like so :) .
Code: [Select]
(defun c:arml (/ ob)
  (or *mleaderoptionglobal* (setq *mleaderoptionglobal* "Add"))
  (initget 0 "Add Remove")
  (setq   *mleaderoptionglobal*
    (cond ((getkword (strcat "\n[Add/Remove] <" *mleaderoptionglobal* ">: ")))
          (*mleaderoptionglobal*)
    )
  )
  (if (setq ob (car (entsel "\nPlease select MULTILEADER: ")))
    (if   (= (cdr (assoc 0 (entget ob))) "MULTILEADER")
      (if (= *mleaderoptionglobal* "Add")
   (command "._mleaderedit" ob pause)
   (command "._mleaderedit" ob "_remove" pause)
      )
      (princ "\n** Object selected was not a multileader. ** ")
    )
    (princ "\n** Nothing selected ** ")
  )
  (princ)
)
i was thinking about this. nice one ronjonp :)
kruuger

ronjonp

  • Needs a day job
  • Posts: 7307
Re: [LISP] Can we add/remove leader to mleader with lisp ?
« Reply #7 on: October 04, 2013, 11:05:34 AM »
 ;D

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC