Author Topic: [XDrX-Function(8)] Programming by Dragging Grips (3)  (Read 702 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Swamp Rat
  • Posts: 527
[XDrX-Function(8)] Programming by Dragging Grips (3)
« on: December 04, 2023, 12:34:32 PM »
Programming by Dragging Grips (1)
https://www.theswamp.org/index.php?topic=58841.msg617609#msg617609

Programming by Dragging Grips (2)
https://www.theswamp.org/index.php?topic=58842.0

This time continue to simulate the STRETCH command, drag the grip point, and complete the alignment of the dimension limits.

Operation process for AUTOCAD users:


Code to simulate the STRETCH command:


Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt ()
  2.   (xdrx-begin)
  3.   (xdrx-sysvar-push '("osmode" 545))
  4.   (if (and (setq dims (xdrx-ssget "\nSelect Dim<Exit>:" '((0 . "dim*"))))
  5.            (setq p1 (getpoint "\nFirst Point<Exit>:"))
  6.            (setq p2 (getpoint p1 "\nSecond Point<Exit>:"))
  7.       )
  8.     (progn
  9.       (mapcar
  10.         '(lambda (dim)
  11.            (if
  12.              (and
  13.                (setq xLine1 (xdrx-getpropertyvalue dim "xline1")
  14.                      xLine2 (xdrx-getpropertyvalue dim "xLine2")
  15.                )
  16.                (setq int1 (xdrx-get-inters (list p1 p2) xLine1 3))
  17.                (setq int2 (xdrx-get-inters (list p1 p2) xLine2 3))
  18.              )
  19.               (progn
  20.                 (setq grips (xdrx-entity-getstretchpoint dim)
  21.                       gPt0  (nth 0 grips)
  22.                       gPt1  (nth 1 grips)
  23.                       ints  (xdrx-points-sortoncurve (append int1 int2)(list gPt0 gPt1))
  24.                       ints (mapcar 'car ints)
  25.                       vec1  (mapcar '- (nth 0 ints) gPt0)
  26.                       vec2  (mapcar '- (nth 1 ints) gPt1)
  27.                 )
  28.                 ;|
  29.                   The corresponding GRIP numbers of dimline1 and dimline2 are 0,1
  30.                 |;
  31.                 (xdrx_entity_movestretchpoint dim vec1 0)
  32.                 (xdrx_entity_movestretchpoint dim vec2 1)
  33.               )
  34.            )
  35.          )
  36.         (xdrx-ss->ents dims)
  37.       )
  38.     )
  39.   )
  40.   (xdrx-sysvar-pop)
  41.   (xdrx-end)
  42.   (princ)
  43. )
« Last Edit: December 04, 2023, 01:31:10 PM 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