Author Topic: [XDrX-PlugIn(16)] Copy local segment from POLYLINE  (Read 959 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Swamp Rat
  • Posts: 527
[XDrX-PlugIn(16)] Copy local segment from POLYLINE
« on: November 28, 2023, 01:47:50 AM »
Code - Auto/Visual Lisp: [Select]
  1. ;|
  2. Function name: XD::Pnt:Mark
  3. Calling format: (XD::Pnt:Mark p col)
  4. Parameter description: p ---- point
  5. col -- color
  6. Return value: t
  7. Function introduction: Draw point markers
  8. Function source: original
  9. Function author: Free-lancer
  10. Applicable versions: no limit
  11. Last updated: 2014-09-22
  12. |;
  13. (defun XD::Pnt:Mark (p col asratio / p1 p2 p3 p4 vs)
  14.   (setq vs (getvar "viewsize"))
  15.   (grvecs
  16.     (list col
  17.           (polar p (/ pi 4) (* vs asratio))
  18.           (polar p (* pi 1.25) (* vs asratio))
  19.           col
  20.           (polar p (* pi 0.75) (* vs asratio))
  21.           (polar p (* pi -0.25) (* vs asratio))
  22.           col
  23.           (setq p1 (polar p (* pi 0.75) (* vs (* (/ asratio 3.0) 2.0))))
  24.           (setq p2 (polar p (/ pi 4) (* vs (* (/ asratio 3.0) 2.0))))
  25.           col
  26.           p2
  27.           (setq p3 (polar p (* pi -0.25) (* vs (* (/ asratio 3.0) 2.0))))
  28.           col
  29.           p3
  30.           (setq p4 (polar p (* pi 1.25) (* vs (* (/ asratio 3.0) 2.0))))
  31.           col
  32.           p4
  33.           p1
  34.     )
  35.   )
  36.   t
  37. )
  38. (defun XD::Pnts:Mark (p col asratio / p1 p2 p3 p4 vs)
  39.   (mapcar '(lambda(x)
  40.               (xd::pnt:mark x col asratio))
  41.               p)
  42.   t
  43. )

The code demonstrates how to let the general drag function "xd::drag:simplemove" handle the callback function "_split-callback" of this program. During the dragging process, if the screen is zoomed, the xd::pnt:mark function is called to always draw the starting point. , the end vector point.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt (/ p1 p2)
  2. ;|
  3.    let the xd::drag:simplemove execute the callback function
  4.    When the screen is zoomed, the starting point of vector
  5.    drawing is always
  6. |;
  7.   (defun _split-callback (dynpt)
  8.     (redraw)
  9.     (xd::pnt:mark p1 2 0.02)
  10.     (xd::pnt:mark p2 2 0.02)
  11.   )
  12.   (xdrx-begin)
  13.   (xdrx-sysvar-push '("osmode" 12))
  14.   (if
  15.     (and (setq
  16.            e
  17.             (car
  18.               (xdrx-entsel "\nPick Polyline<Exit>:" '((0 . "*polyline")))
  19.             )
  20.          )
  21.          (xdrx-entity-redraw e 3)
  22.          (setq p1 (cadr (xdrx-entsel "\nStart point<exit>:")))
  23.          (setq inx1 (xdrx-getpropertyvalue e "nearindex" (trans p1 1 0))
  24.                p1   (xdrx-getpropertyvalue e "pointat" inx1)
  25.          )
  26.          (xd::pnt:mark p1 2 0.02)
  27.          (setq p2 (cadr (xdrx-entsel "\nTermination point<exit>:")))
  28.          (setq inx2 (xdrx-getpropertyvalue e "nearindex" (trans p2 1 0))
  29.                p2   (xdrx-getpropertyvalue e "pointat" inx2)
  30.          )
  31.          (xd::pnt:mark p2 2 0.02)
  32.          (setq inx (vl-sort (list inx1 inx2) '<))
  33.          (setq ge   (xdge::constructor e)
  34.                from (car inx)
  35.                to   (cadr inx)
  36.                from (xdge::getpropertyvalue
  37.                       ge
  38.                       "paramof"
  39.                       (xdrx-getpropertyvalue e "pointat" from)
  40.                     )
  41.                to   (xdge::getpropertyvalue
  42.                       ge
  43.                       "paramof"
  44.                       (xdrx-getpropertyvalue e "pointat" to)
  45.                     )
  46.                intv (xdge::constructor "AcGeInterval" from to)
  47.          )
  48.     )
  49.      (progn
  50.        (xdge::setpropertyvalue ge "setinterval" intv)
  51.        (setq pl (xdge::entity:make ge))
  52.        (xdrx-entity-matchprop e pl)
  53.        (XD::Drag:CallBackSetMouseMove "_split-callback")
  54. ;|
  55. Let the xd::drag:simplemove drag function additionally execute
  56. the callback function "_split-callback" of this program
  57. |;
  58.        (xd::drag:simplemove pl  "\nInsert Point:" 5 t)
  59.        (xdrx-entity-redraw e 4)
  60.        (redraw)
  61.      )
  62.   )
  63.   (xdrx-sysvar-pop)
  64.   (xdrx-end)
  65.   (princ)
  66. )
  67.  
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