CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 文档中心

vlax-tmatrix (AutoLISP/ActiveX)

2023-1-7 09:42| 发布者: admin| 查看: 196| 评论: 0|来自: AutoCAD

摘要: 返回要在 VLA 方法中使用的 4 x 4 转换矩阵的合适表示形式

返回要在 VLA 方法中使用的 4 x 4 转换矩阵的合适表示形式

支持的平台:仅窗口

签名

(vlax-tmatrix lst)
lst

类型:列表

四个列表的值,每个列表包含四个数字,表示转换矩阵元素。

返回值

类型:变体

安全数组类型的变体,表示 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)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 14:31

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部