【发布时间】:2021-08-13 09:20:47
【问题描述】:
我正在使用 CATIA V5R27 工作。自动化的手动操作首先是切换到“DMU Navigator”工作台。然后我激活一个节点并单击“Translation or Rotation”按钮。之后我选择“Position”选项卡并检查数据。
谁能告诉我该怎么做或者我应该使用哪个库?
【问题讨论】:
我正在使用 CATIA V5R27 工作。自动化的手动操作首先是切换到“DMU Navigator”工作台。然后我激活一个节点并单击“Translation or Rotation”按钮。之后我选择“Position”选项卡并检查数据。
谁能告诉我该怎么做或者我应该使用哪个库?
【问题讨论】:
您必须获得您感兴趣的 Instance Product 对象,然后您才能从 Product 的 Position 属性中获得它的转换矩阵。所以像:
// get CATIA object
var oCATIA = (INFITF.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("CATIA.Application");
// Get active document
var oDoc = oCATIA.ActiveDocument;
// get the instance product of the selected object
var oInstProd = (Product)oDoc.Selection.Item(1).LeafProduct;
// declare a safe array for the transformation matrix
Array tx = Array.CreateInstance(typeof(object), 12);
// get the transformation matrix components
oInstProd.Position.GetComponents(tx);
//print the results
System.Diagnostics.Debug.Print(((object[])tx)[0].ToString() + ", " + ((object[])tx)[1].ToString() + ", " + ((object[])tx)[2].ToString());
System.Diagnostics.Debug.Print(((object[])tx)[3].ToString() + ", " + ((object[])tx)[4].ToString() + ", " + ((object[])tx)[5].ToString());
System.Diagnostics.Debug.Print(((object[])tx)[6].ToString() + ", " + ((object[])tx)[7].ToString() + ", " + ((object[])tx)[8].ToString());
System.Diagnostics.Debug.Print(((object[])tx)[9].ToString() + ", " + ((object[])tx)[10].ToString() + ", " + ((object[])tx)[11].ToString());
这是该特定节点的变换矩阵。如果节点是其他产品的子节点,则必须将此矩阵与其父节点的矩阵相乘才能得到绝对变换。
您将需要类型库 INFITF 和 ProductStructureTypeLib 作为参考。
【讨论】: