vlax-tmatrix (AutoLISP/ActiveX)
返回要在 VLA 方法中使用的 4 x 4 转换矩阵的合适表示形式 支持的平台:仅限 Windows 签名(vlax-tmatrix lst)
返回值类型:变体 safearray 类型的变体,表示 4×4 变换矩阵。 例子定义一个变换矩阵并将其值赋给变量:tmatrix (setq tmatrix (vlax-tmatrix '((1 1 1 0) (1 2 3 0) (2 3 4 5) (2 9 8 3)))) #<variant 8197 ...> 用于查看列表形式的值:vlax-safearray->listtmatrix (vlax-safearray->list (vlax-variant-value tmatrix)) ((1.0 1.0 1.0 0.0) (1.0 2.0 3.0 0.0) (2.0 3.0 4.0 5.0) (2.0 9.0 8.0 3.0)) 下面的代码示例创建一条线,并使用变换矩阵将其旋转 90 度: (defun Example_TransformBy ( / acadObject acadDocument mSpace lineObj
startPt endPt matList transMat)
(vl-load-com) ; Load ActiveX support
(setq acadObject (vlax-get-acad-object))
(setq acadDocument (vla-get-ActiveDocument acadObject))
(setq mSpace (vla-get-ModelSpace acadDocument))
;;; Create a line
(setq startPt (getpoint "\nPick the start point: "))
(setq endPt (vlax-3d-point (getpoint startPt "\nPick the end point: ")))
(setq lineObj (vla-addline mSpace (vlax-3d-point startPt) endPt))
;;; Initialize the transMat variable with a transformation matrix
;;; that will rotate an object by 90 degrees about the point(0,0,0).
;;; Begin by Creating a list of four lists, each containing four
;;; numbers, representing transformation matrix elements.
(setq matList (list '(0 -1 0 0) '(1 0 0 0) '(0 0 1 0) '(0 0 0 1)))
;;; Use vlax-tmatrix to convert the list to a variant.
(setq transmat (vlax-tmatrix matlist))
;;; Transform the line using the defined transformation matrix
(vla-transformby lineObj transMat)
(vla-zoomall acadObject)
(prompt "\nThe line has been transformed.")
(princ)
)
相关参考 |
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-30 07:08
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.