我正在尝试使用 VBA 脚本连接 Autodesk Inventor 中的两个实体模型配置文件。我已经绘制了 3D 线条,这些线条应该在以后充当轮廓。脚本完成绘制后,我可以选择两个循环并通过 GUI 使用 loft 操作将它们连接起来。我认为这也应该可以从脚本中获得,我只是无法弄清楚如何。到目前为止,这是我的脚本:
Sub loft()
Set oDoc = ThisApplication.Documents.Add(kPartDocumentObject, , True)
Set oPartDef = oDoc.ComponentDefinition
Dim osketch3D As Sketch3D
Set osketch3D = oPartDef.Sketches3D.Add()
Set oTG = ThisApplication.TransientGeometry
Dim wire(198) As SketchLine3D
Set wire(0) = osketch3D.SketchLines3D().AddByTwoPoints(oTG.CreatePoint(0, 0, 0), oTG.CreatePoint(10, 0, 0))
Set wire(1) = osketch3D.SketchLines3D().AddByTwoPoints(oTG.CreatePoint(10, 0, 0), oTG.CreatePoint(10, 10, 1))
Set wire(2) = osketch3D.SketchLines3D().AddByTwoPoints(oTG.CreatePoint(10, 10, 1), oTG.CreatePoint(0, 10, 0))
Set wire(3) = osketch3D.SketchLines3D().AddByTwoPoints(oTG.CreatePoint(0, 10, 0), oTG.CreatePoint(0, 0, 0))
Set wire(4) = osketch3D.SketchLines3D().AddByTwoPoints(oTG.CreatePoint(0, 0, 5), oTG.CreatePoint(10, 0, 5))
Set wire(5) = osketch3D.SketchLines3D().AddByTwoPoints(oTG.CreatePoint(10, 0, 5), oTG.CreatePoint(10, 10, 5))
Set wire(6) = osketch3D.SketchLines3D().AddByTwoPoints(oTG.CreatePoint(10, 10, 5), oTG.CreatePoint(0, 10, 5))
Set wire(7) = osketch3D.SketchLines3D().AddByTwoPoints(oTG.CreatePoint(0, 10, 5), oTG.CreatePoint(0, 0, 5))
' .....
' Select wires 0-3 and 4-7 as profiles, put them in an object collection and call the loft op.
End Sub