Author Topic: [AcGe(6)] AcGeMatrix3d - Matrix operation application examples(2)-Mirror  (Read 405 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Swamp Rat
  • Posts: 514
Regarding the basic concepts of AcGeMatrix3d and simple methods of implementing COPY and MOVE, see the post:
https://www.theswamp.org/index.php?topic=58880.msg617740#msg617740

======================

Use the mirror transformation matrix under AcGeMatrix3d and cooperate with the point monitor to implement the original AUTOCAD mirror command:



Code - Auto/Visual Lisp: [Select]
  1. (defun c:mir ()
  2.   (defun _call-back (dynpt)
  3.     (xdrx-entity-delete clone)
  4.     (setq mat-mirror
  5.            (xdrx-matrix-setmirror (list base dynpt))
  6.     )
  7.     (setq clone (xdrx-entity-transformedcopy ents mat-mirror))
  8.   )
  9.   (xdrx-entity-transform clone mat-translation)
  10.   (if
  11.     (and (setq ss (xdrx-ssget "\nSelect the object to be moved <exit>:"))
  12.          (setq p1 (getpoint "\nThe first point of the mirror axis<exit>:"))
  13.     )
  14.      (progn
  15.        (xdrx-begin)
  16.        (setq ents  (xdrx-ss->ents ss)
  17.              clone (xdrx-entity-copy ss)
  18.        )
  19.        (setq base p1)
  20.        (xdrx-pointmonitor "_call-back")
  21.        (if (setq p2 (getpoint p1 "\nMirror axis Second point <Exit>:"))
  22.          (progn
  23.            (if (and (xdrx-initget "Y N")
  24.                     (= 0
  25.                        (xdrx-yesorno
  26.                          "\nWhether to keep the original object:"
  27.                          1
  28.                        )
  29.                     )
  30.                )
  31.              (xdrx-entity-delete ents)
  32.            )
  33.          )
  34.        )
  35.        (xdrx-pointmonitor)
  36.        (xdrx-end)
  37.      )
  38.   )
  39.   (princ)
  40. )
« Last Edit: December 12, 2023, 02:27:27 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