我已经标记了发生错误的行。
语言="VBSCRIPT"
Sub CATMain()
Dim ProdDoc As Document
Set ProdDoc = CATIA.ActiveDocument
Dim product1 As Product
Set product1 = ProdDoc.Product
Dim products1 As Products
Set products1 = product1.Products
Dim product2 As Product
Set product2 = products1.AddNewComponent("Part", "NewPart1")
Dim documents1 As Documents
Set documents1 = CATIA.Documents
Dim partDocument1 As Document
Set partDocument1 = documents1.Item("NewPart1.CATPart")
Dim NewPart1 As Part
Set NewPart1 = partDocument1.Part
Dim hybridShapeFactory1 As Factory
Set hybridShapeFactory1 = NewPart1.HybridShapeFactory
Dim parameters1 As Parameters
Set parameters1 = NewPart1.Parameters
Dim oSel As Selection
Set oSel = prodDoc.Selection
Dim point_ref
Dim line_ref
Dim Point As Reference
Dim Line As Reference
'选择点和边的变量
Dim iot1(0)
iot1(0) = "Vertex"
Dim iot2(0)
iot2(0)="TriDimFeatEdge"
Status = oSel.SelectElement2(iot1, "Select a line", False)
msgbox oSel.Item(1).Type
set point_ref = oSel.Item(1).Value
oSel.Clear
Status = oSel.SelectElement2(iot2, "Select a line", False)
msgbox oSel.Item(1).Type
set line_ref = oSel.Item(1).Value
oSel.Clear
' 传递选定的点和线来创建一个新平面。' 使用垂直于曲线的方法创建平面。
Dim hybridShapePlaneNormal1 As HybridShapePlaneNormal
Set hybridShapePlaneNormal1 = hybridShapeFactory1.AddNewPlaneNormal(line_ref, point_ref)
Dim bodies1 As Bodies
Set bodies1 = NewPart1.Bodies
Dim body1 As Body
Set body1 = bodies1.Item("PartBody")
' This is where I get error
body1.InsertHybridShape hybridShapePlaneNormal1 '{Error - Method InsertHybridShape failed}
NewPart1.InWorkObject = hybridShapePlaneNormal1
NewPart1.Update
End Sub