我想在宏中将草图支持从一个平面更改为另一个平面。我尝试使用 StartCommand,但没有奏效。在没有用户输入的情况下如何做到这一点?
我已经尝试了以下代码,但它没有工作。
CATIA.StartCommand "Change Sketch Support"
selection1.Add sketch3
SendKeys "{ENTER}", True
selection1.Add Plane_a
SendKeys "{ENTER}", True
part1.Update
此链接说选择草图然后选择平面并运行 StartCommand“更改草图支持”
'Get the part object (Assume the part is open in it’s own window)
Set objPart = CATIA.ActiveDocument.Part
'Get the first sketch in the first geometrical set
Set objSketch = objPart.HybridBodies.Item(1).HybridSketches.Item(1)
'Get the plane called Plane.1 in the first geometrical set
Set objPlane = objPart.HybridBodies.Item(1).HybridShapes.Item(“Plane.1”)
'Select the sketch first then the new support plane
Set objSel = CATIA.ActiveDocument.Selection
objSel.Clear
objSel.Add objSketch
objSel.Add objPlane
'Call the Change Sketch Support command
CATIA.StartCommand “Change Sketch Support”
您正在尝试使用 winapi,这不是最简单的方法。您有两种选择:
或者您使用复制和粘贴方法
Dim osel As Selection = CATIA.ActiveDocument.Selection
osel.Clear()
osel.Add(sketch3)
osel.Copy()
osel.Clear()
osel.Add(Plane_a)
osel.Paste()
Dim RsltSketch As Sketch = osel.Item2(1).Value
osel.Clear()
'You can delete the first one if you want
osel.Add(sketch3)
osel.Delete()
或者你定义精确的向量
Dim arrayOfVariantOfDouble(8)
arrayOfVariantOfDouble(0) = OriginPointX
arrayOfVariantOfDouble(1) = OriginPointY
arrayOfVariantOfDouble(2) = OriginPointZ
arrayOfVariantOfDouble(3) = DirectionHorizontalX
arrayOfVariantOfDouble(4) = DirectionHorizontalY
arrayOfVariantOfDouble(5) = DirectionHorizontalZ
arrayOfVariantOfDouble(6) = DirectionVerticalX
arrayOfVariantOfDouble(7) = DirectionVerticalY
arrayOfVariantOfDouble(8) = DirectionVerticalZ
sketch3.SetAbsoluteAxisData(arrayOfVariantOfDouble)