使用AIP通过三个点的XYZ坐标建立工作平面失败

Ruankaixin
Participant
Participant

使用AIP通过三个点的XYZ坐标建立工作平面失败

Ruankaixin
Participant
Participant

各位大佬,我的需求是创建新零件文档,之后在零件文档内通过三个点的XYZ坐标创建工作平面,之后在此工作平面进行其他操作,但当代码运行到创建工作平面时报错,以下是我的代码,请各位大佬指点。

// 创建一个新的零件文档
PartDocument partDoc = (PartDocument)inventorApp.Documents.Add(
DocumentTypeEnum.kPartDocumentObject,
inventorApp.FileManager.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject), true);
// 获取 ComponentDefinition 对象
PartComponentDefinition compDef = partDoc.ComponentDefinition;
// 获取TransientGeometry对象,用于执行几何操作
TransientGeometry transientGeometry = inventorApp.TransientGeometry;

// 定义3D点
Point EquipCP1 = transientGeometry.CreatePoint(-19.67756345, -14.88854191, -4.6);
Point EquipCP2 = transientGeometry.CreatePoint(-19.67756345, -14.88854191, -5.2);
Point EquipCP3 = transientGeometry.CreatePoint(-19.91632049, -14.56761346, -5.2);

// 创建一个工作平面,通过EquipCP1, EquipCP2, EquipCP3定义的平面

WorkPlane workPlane = compDef.WorkPlanes.AddByThreePoints(EquipCP1, EquipCP2, EquipCP3);

//AddByThreePoins报错

//求指点

0 个赞
回复
603 次查看
3 条回复
回复 (3)

王承之pmhker
Advisor
Advisor
已接受的解答

我对C#语法不太熟悉,你可以参考下如下VB代码

partDoc = ThisApplication.ActiveDocument
compDef = partDoc.ComponentDefinition
TG = ThisApplication.TransientGeometry
'定义工作点坐标
Point1 = TG.CreatePoint(0, 0, 0)
Point2 = TG.CreatePoint(10, 0, -5)
Point3 = TG.CreatePoint(0, 10, 0)
'创建三个工作点
wpoint1 = compDef.WorkPoints.AddFixed(Point1) 
wpoint2 = compDef.WorkPoints.AddFixed(Point2) 
wpoint3 = compDef.WorkPoints.AddFixed(Point3) 
'根据三个工作点创建工作平面
workPlane1 = compDef.WorkPlanes.AddByThreePoints(wpoint1, wpoint2, wpoint3)


If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!
如果我的回帖解决了您的问题,请点击 "接受为解决方案" 按钮. 这可以帮助其他人更快的找到解决方案!


王 承之
Autodesk AGN [Inventor 俱乐部] Leader
Inventor Club | Bilibili


AGN L    EESignature

Ruankaixin
Participant
Participant
已接受的解答

感谢老师之前的回复,我这边遇到点新问题,请老师指教

EquipCP1 X:-25.85222728 Y:-8.145459308 Z:-2.849999675

EquipCP2 X:-25.85222264 Y:-8.145457858 Z:-3.149999675

EquipCP3 X:-25.89690385 Y:-8.002267113 Z:-3.149999675

EquipCP4 X:-25.89690849 Y:-8.002268564 Z:-2.849999675

EquipCP7 X:-25.87131938 Y:-8.151416803 Z:-2.85

我通过1-4点的坐标生成了一个工作平面,并在这个工作平面创建了一个长方形,现需要将长方形拉伸为长方体,7点事与1点对应的长方体顶点坐标,如何将长方形向7点方向拉伸为长方体

0 个赞

王承之pmhker
Advisor
Advisor
已接受的解答

不同主题建议重新发帖,谢谢


If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!
如果我的回帖解决了您的问题,请点击 "接受为解决方案" 按钮. 这可以帮助其他人更快的找到解决方案!


王 承之
Autodesk AGN [Inventor 俱乐部] Leader
Inventor Club | Bilibili


AGN L    EESignature