Author Topic: [AcGe(10)] AcGeMatrix3d - Matrix Operation (6)-Ent transform in different Coords  (Read 419 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

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