Author Topic: Mleader drawing Entmake or visual Lisp ?? (Figure includes)  (Read 5631 times)

0 Members and 1 Guest are viewing this topic.

rlxozzang

  • Guest
Mleader drawing Entmake or visual Lisp ?? (Figure includes)
« on: October 04, 2012, 11:15:57 PM »
To Mleader LISP site when I search for it on the s command syntax. entmake or Visual Lisp Is it possible? ^-^

Code: [Select]
(defun c:DrawMleader (/ cc_echo cc_ss cc_texteval CL)
(command ".undo" "begin")
(setq CL (getvar "CLAYER"))
; (LoadMLstyle)
; (set-ML-layer)
(setq cc_texteval (getvar "texteval"))
(setvar "texteval" 1)
(setq cc_echo (getvar "cmdecho"))
(setvar "cmdecho" 1)
; (command "_.acad_dim.mleader")
; (while (= (logand (getvar "cmdactive") 1) 1)
; (command pause)
; )

(command "_.acad_dim.mleader" pause pause "")

(setvar "cmdecho" cc_echo)
(setvar "texteval" cc_texteval)
(setq cc_ss (entlast))
(if (= (vla-get-ContentType (vlax-ename->vla-object cc_ss)) 2) ;check availability of mtext content
(command "_.ddedit" cc_ss "") ;edit text and exit command
)
(setvar "CLAYER" CL)
(command ".undo" "end")
(princ)
)
« Last Edit: October 05, 2012, 04:45:12 AM by rlxozzang »

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Mleader drawing Entmake or visual Lisp ?? (Figure includes)
« Reply #1 on: October 05, 2012, 04:56:21 AM »
You can use VLisp and work with the ActiveX objects. The model space object's AddMLeader method can do this for you, it creates a MLeader without any attachments (i.e. text/block). It returns a MLeader object which you can then set properties on as you wish.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

rlxozzang

  • Guest
Re: Mleader drawing Entmake or visual Lisp ?? (Figure includes)
« Reply #2 on: October 09, 2012, 08:47:47 PM »
You can use VLisp and work with the ActiveX objects. The model space object's AddMLeader method can do this for you, it creates a MLeader without any attachments (i.e. text/block). It returns a MLeader object which you can then set properties on as you wish.

Lack of my skills to a visual approach to help the Lisp examples, the question once again sought help. ㅜ ㅜ :cry: :cry:

DW

  • Newt
  • Posts: 23
Re: Mleader drawing Entmake or visual Lisp ?? (Figure includes)
« Reply #3 on: October 11, 2012, 11:05:08 AM »
Here's a Multileader routine which utilises a standard mleader style assuming it has one leader and some text rather than a block.  I've put it in a grread  loop so its a bit more dynamic. 

You might want to set up or modify an existing multilieader style before using it. 

Hope this helps  :-)

Code - Auto/Visual Lisp: [Select]
  1. (defun c:vlMl (/ p1 p2 label input *lead)
  2.  
  3.   (if (and (setq label (getstring T "\nSpecify label text"))
  4.            (setq p1 (getpoint "\nPick Mulitleader start point"))
  5.       )
  6.    
  7.   (progn (setq p2 p1)
  8.          (princ "\nPick label location")
  9.          (while (and p2
  10.                      (setq input (grread t 9 0))
  11.                      (or (= (car input) 5) (= (car input) 3) (= (car input) 2))
  12.                 )
  13.            (cond ((= (car input) 5) (mkmleader (cadr input))) ;tracking coordinates returned
  14.                  
  15.                  ((= (car input) 2) (setq p2 nil) (if *lead (vla-delete *lead))) ;keyboard input - exit
  16.                  
  17.                  ((= (car input) 3) (setq p2 nil));point picked - exit while loop
  18.                  
  19.                  (T (setq p2 nil)(if *lead (vla-delete *lead)))
  20.            )
  21.          )
  22.     (princ)
  23.   )
  24. )
  25.   )
  26.  
  27. (defun mkmleader ( p2 / pts)
  28.  
  29.   (if (not *lead);create the multileader if it doesn't exist
  30.      (progn (setq pts (list (trans p1 1 0) (trans p2 1 0))
  31.                   pts (gc:3dPointListToVariant pts)
  32.             )
  33.            (setq *lead (vla-AddMLeader
  34.                         (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)));get modelspace object
  35.                         pts
  36.                         0
  37.                       )
  38.            )
  39.            (vla-put-textstring *lead label)
  40.            (vla-rotate
  41.              *lead
  42.              (vlax-3d-point (trans p2 1 0))
  43.              (angle (trans '(0 0 0) 1 0) (trans '(1 0 0) 1 0))
  44.            )
  45.       )
  46.     ;the object already exists so just update it
  47.     (progn
  48.       (setq pts (list (trans p1 1 0) (trans p2 1 0))
  49.             pts (gc:3dPointListToVariant pts))
  50.      
  51.       (vla-SetLeaderLineVertices *lead 0 pts);redefine the vertices
  52.       (vla-SetDogLegDirection *lead 0 (vlax-3D-point (trans (list (if (> (car p2) (car p1)) 1 -1) 0 0) 1 0 T)));change direction of dogleg according to cursor position relative to start point
  53.       (vla-update *lead)
  54.     )
  55.   )
  56. )
  57.  
  58. ;; Thanks to Gile!
  59. ;;
  60. ;; Return a variant of 3d coordinates
  61. ;;
  62. ;; Argument: a 3d points list -type (x y z)-
  63.  
  64. (defun gc:3dPointListToVariant (lst)
  65.   (vlax-make-variant
  66.       (vlax-make-safearray
  67.         vlax-VbDouble
  68.         (cons 0 (1- (* 3 (length lst))))
  69.       )
  70.       (apply 'append lst)
  71.     )
  72.   )
  73. )
  74.  

rlxozzang

  • Guest
Re: Mleader drawing Entmake or visual Lisp ?? (Figure includes)
« Reply #4 on: October 11, 2012, 09:06:44 PM »
Here's a Multileader routine which utilises a standard mleader style assuming it has one leader and some text rather than a block.  I've put it in a grread  loop so its a bit more dynamic. 

You might want to set up or modify an existing multilieader style before using it. 

Hope this helps  :-)
DW Thank you.^ ^ Multileader saw a ray of light.