我正在制作创建平面的脚本。我想为此飞机添加自定义颜色。 为此,我使用Selection.Search方法。但是我收到错误消息:“调用Sub时不能使用括号”。
Sub CATMain()
Dim Part as PartDocument
Set Part = CATIA.activeDocument.Part
LengthDimension = 150
Set ReferenceGeom = Part.HybridBodies.Item("Skeleton").HybridBodies.Item("2. Reference geometry")
Part.InWorkObject = ReferenceGeom
For i = 1 to 2
Call AddPlane(ReferenceGeom,Part,"ZX",LengthDimension,i,i)
Next
For j = 1 to 2
Call AddPlane(ReferenceGeom,"YZ",j,j + 2)
Next
For k = 1 to 2
Call AddPlane(ReferenceGeom,"XY",k,k + 4)
Next
End Sub
Sub AddPlane(PointGeomSet As HybridBody,RefPart As PartDocument,Plane As String,PlaneOffset As Real,n As Integers)
PlaneName = n & ". " & PlaneNamesArr(n - 1)
.... Code to create planes (worked good)
Set Sel = CATIA.activeDocument.Selection
Sel.Search("Name=" & PlaneName & "*,all")
Set PlaneColor = Sel.VisProperties
PlaneColor.SetRealColor(0,255,0) <- Here I got an error
Sel.Clear
End Sub
或者也许还有另一种改变平面颜色的方法?