Author Topic: [XDrX-PlugIn(32)] DYN Drag the four quadrants to Change the MLeader Direction  (Read 963 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Swamp Rat
  • Posts: 527
Code - Auto/Visual Lisp: [Select]
  1. (defun c:xdtb_mleaderdragfx (/ e msg my_err old str tf)
  2.    (defun my_err (msg)
  3.      (princ "\n")
  4.      (princ msg)
  5.      (xdrx_end)
  6.      (vl-cmdf ".undo" 1)
  7.      (redraw)
  8.    )
  9.    (xd::doc:checkacadversion '> "2008" "")
  10.    (xdrx_begin)
  11.    (setq *error* my_err)
  12.    (if (setq e (car (xdrx-entsel
  13.                       "\nSelect multileader<Exit>:"
  14.                       '((-4 . "<or")
  15.                         (0 . "MULTILEADER")
  16.                         (2 . "XMLEADER*")
  17.                         (-4 . "or>")
  18.                        )
  19.                     )
  20.                )
  21.        )
  22.      (progn
  23.        (if (setq tf (xdrx-object-isa e "AcDbBlockreference"))
  24.          (progn (setq old e)
  25.                 (xdrx-entity-explode e)
  26.                 (setq e (entlast))
  27.          )
  28.        )
  29.        (xd::mleader:drag
  30.          e
  31.          "\nMove the mouse to determine the direction<Exit>:"
  32.          1
  33.        )
  34.        (if tf
  35.          (progn
  36.            (setq str (strcat "XMLEADER-"
  37.                              (xdrx-getpropertyvalue e "handle")
  38.                      )
  39.            )
  40.            (xdrx_block_make
  41.              str
  42.              e
  43.              (xdrx-getpropertyvalue e "firstvertex" 0)
  44.              t
  45.            )
  46.            (xdrx-entity-setpropertiesfrom (entlast) e)
  47.            (xdrx-object-swapid (entlast) old)
  48.          )
  49.        )
  50.      )
  51.    )
  52.    (setq *error* nil)
  53.    (xdrx_end)
  54.    (princ)
  55. )
  56.  


Input Point Monitor to realize dynamic dragging MLEADER
Function: XD::MLeader:Drag
The function has been encapsulated in xd-lisp-lib.vlx,

Code - Auto/Visual Lisp: [Select]
  1. ;|
  2. XD::MLeader:Drag
  3. Input Point Monitor to realize dynamic dragging MLEADER
  4. parameter:
  5.     e ---- mleader entity name
  6.     info ---- prompt string
  7.     clr ---- crosshair axis color
  8. Return: T
  9. |;
  10. (defun XD::MLeader:Drag
  11.        (e info clr / dynpt old pnt qua quadrantpnt str tf x)
  12.   (defun _callback (dynpt)
  13.     (redraw)
  14.     (setq qua (xdrx_getpropertyvalue e "quadrant" dynpt)
  15.           pnt (nth (1- qua) #quadrantpoint)
  16.     )
  17.     (xdrx_setpropertyvalue e "lastvertex" (list 0 pnt))
  18.     (setq h  (/ (getvar "viewsize") 10.0)
  19.           p1 (polar #firstvertex an h)
  20.           p2 (polar #firstvertex an (- h))
  21.           p3 (polar #firstvertex (+ an (/ pi 2.0)) h)
  22.           p4 (polar #firstvertex (+ an (/ pi 2.0)) (- h))
  23.     )
  24.     (xdrx_grdraw clr clr (list p1 p2))
  25.     (xdrx_grdraw clr clr (list p3 p4))
  26.   )
  27.   (if (setq tf (xdrx_object_isa e "AcDbBlockreference"))
  28.     (progn (setq old e)
  29.            (xdrx_entity_explode e)
  30.            (setq e (entlast))
  31.     )
  32.   )
  33.   (setq #firstvertex (xdrx_getpropertyvalue e "firstvertex" 0))
  34.   (setq #quadrantpoint (xdrx_getpropertyvalue e "quadrantpoint"))
  35.   (setq lxd #quadrantpoint)
  36.   (setq xdir (xdrx_entity_direction e)
  37.         an   (xdrx_vector_angle xdir)
  38.   )
  39.   (xdrx_pointmonitor "_callback")
  40.   (getpoint info)
  41.   (redraw)
  42.   (xdrx_pointmonitor)
  43.   (if tf
  44.     (progn (setq str (strcat "XMLEADER-" (xdrx_getpropertyvalue e "handle")))
  45.            (xdrx_block_make
  46.              str
  47.              e
  48.              (xdrx_getpropertyvalue e "firstvertex" 0)
  49.              t
  50.            )
  51.            (xdrx_entity_setpropertiesfrom (entlast) e)
  52.            (xdrx_object_swapid (entlast) old)
  53.     )
  54.   )
  55.   t
  56. )
  57.  
« Last Edit: December 03, 2023, 09:19:14 AM by xdcad »
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net