Author Topic: [AcGe(12)] Matrix transformation(7) - Copy entities between different coords  (Read 414 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Swamp Rat
  • Posts: 505
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

Transformation between different coordinate systems is a challenging task, but it is extremely convenient because ARX AcGeMatrix3d provides the AcGeMatrix3d::alignCoordSys method. This function is also the most distinctive function of AcGeMatrix3d.



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

result:


The video above demonstrates the copying of text in different coordinate systems.

==========

Code - Auto/Visual Lisp: [Select]
  1. ;|
  2. 1. Key function to construct transformation matrices of different coordinate systems.
  3. 2.from: source coordinate system, (base point x-axis vector y-axis vector z-axis vector)
  4. 3.to: target coordinate system, (base point x-axis vector y-axis vector z-axis vector)
  5. |;
  6.  
  7. (setq mat (xdrx-matrix-aligncoordsystem from to))
  8.  
  9.  

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt(/ box coord_from coord_to e1 m_from mat  p0  px pz base vx vy vz)
  2.   (if (and
  3.         (setq e1 (car (xdrx-entsel "\nPick Circle<exit>:" '((0 . "circle")))))
  4.         (setq base (getpoint "\nbase point<exit>:"))
  5.         (setq p0 (getpoint "\nTarget X-axis first point <exit>:"))
  6.         (setq px (getpoint "\nTarget X-axis second point <exit>:"))
  7.         (setq dest (getpoint p0 "\nInsert Point<exit>:"))
  8.       )
  9.     (progn
  10.       (setq coord_from (xdrx-entity-getecs e1))
  11.       (setq coord_from (cons base (cdr coord_from)))
  12.       (setq vx (xdrx-vector-normalize (mapcar '- px p0)))
  13.       (setq vz (xdrx-vector-negate (xdrx-vector-perpvector vx)))
  14.       (setq vy (xdrx-vector-crossproduct vz vx))
  15.       (setq coord_to (list dest vx vy vz))
  16.       (setq mat (xdrx-matrix-aligncoordsystem coord_from coord_to))
  17.       (xdrx-entity-transformedcopy e1 mat)
  18.       (xdrx-entity-setcolor (entlast) 1)
  19.     )
  20.   )
  21.   (princ)
  22. )
« Last Edit: December 12, 2023, 12:10:41 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