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

0 Members and 1 Guest are viewing this topic.

• Swamp Rat
• Posts: 528
##### [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.     (list col
16.           (polar p (/ pi 4) (* vs asratio))
17.           (polar p (* pi 1.25) (* vs asratio))
18.           col
19.           (polar p (* pi 0.75) (* vs asratio))
20.           (polar p (* pi -0.25) (* vs asratio))
21.           col
22.           (setq p1 (polar p (* pi 0.75) (* vs (* (/ asratio 3.0) 2.0))))
23.           (setq p2 (polar p (/ pi 4) (* vs (* (/ asratio 3.0) 2.0))))
24.           col
25.           p2
26.           (setq p3 (polar p (* pi -0.25) (* vs (* (/ asratio 3.0) 2.0))))
27.           col
28.           p3
29.           (setq p4 (polar p (* pi 1.25) (* vs (* (/ asratio 3.0) 2.0))))
30.           col
31.           p4
32.           p1
33.     )
34.   )
35.   t
36. )
37. (defun XD::Pnts:Mark (p col asratio / p1 p2 p3 p4 vs)
38.   (mapcar '(lambda(x)
39.               (xd::pnt:mark x col asratio))
40.               p)
41.   t
42. )

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)
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.        (xdge::setpropertyvalue ge "setinterval" intv)
50.        (setq pl (xdge::entity:make ge))
51.        (xdrx-entity-matchprop e pl)
52.        (XD::Drag:CallBackSetMouseMove "_split-callback")
53. ;|
54. Let the xd::drag:simplemove drag function additionally execute
55. the callback function "_split-callback" of this program
56. |;
57.        (xd::drag:simplemove pl  "\nInsert Point:" 5 t)
58.        (xdrx-entity-redraw e 4)
59.        (redraw)
60.      )
61.   )
62.   (xdrx-sysvar-pop)
63.   (xdrx-end)
64.   (princ)
65. )
66.
The code I wrote uses XDRX-API，which can be downloaded from github.com and is updated at any time.
===================================