CATBody の色を読み取ることはできますか? 何かのようなもの:
For Each myBody In myPart.Bodies
myColor = myBody.Color
Next
はい、可能ですが、簡単ではありません。色は から入手できVisProperties
ますSelection
。また、これは遅延バインディングを使用する必要がある Catia API の奇妙なケースの 1 つです (理由はわかりません)。
次に例を示します。
Option Explicit
Sub BodyColors()
Dim sel As Selection
Dim selected As SelectedElement
Dim vis As Variant 'VisPropertySet 'This must be variant for late binding. Otherwise you get an error.
Dim RGB(3) As Long 'or you can use an array
Dim r, g, b As Long
Dim myPart As Part
Dim myBody As Body
Set myPart = CATIA.ActiveDocument.Part
Set sel = CATIA.ActiveDocument.Selection
For Each myBody In myPart.Bodies
sel.Clear
sel.Add myBody
Set vis = sel.VisProperties
vis.GetRealColor r, g, b 'you must pass the values into the function
Debug.Print myBody.Name & ": "; r & "," & g & "," & b
Next
sel.clear
End Sub