Reubot
Aerospace
- Apr 25, 2017
- 5
Hello everyone,
I am trying to apply a coloring scheme to a selection of elements but I'm having some trouble. Maybe someone can help?
Problem is as follows:
I want to select a whole bunch of thickness features all with different values, Then I want to assign a color to the thickness feature based on its thickness value. I plan to use an array to define the coloring scheme in RGB values, but I have not gotten that far yet.
Up to now I have used the selectelement3 tool to make a multiselection of the thickness features and just written a simple for loop to cyle through all the features. I though I would be able to apply the visproperties method to change the color of each thickness individually but I am getting an error message that the object does not support this property r method.
In the code below I made a simple rule for the coloring just to check whether anything changes. Please ignore the minimal error handling attempt...im still pretty new at this.
Can anyone help?
I am trying to apply a coloring scheme to a selection of elements but I'm having some trouble. Maybe someone can help?
Problem is as follows:
I want to select a whole bunch of thickness features all with different values, Then I want to assign a color to the thickness feature based on its thickness value. I plan to use an array to define the coloring scheme in RGB values, but I have not gotten that far yet.
Up to now I have used the selectelement3 tool to make a multiselection of the thickness features and just written a simple for loop to cyle through all the features. I though I would be able to apply the visproperties method to change the color of each thickness individually but I am getting an error message that the object does not support this property r method.
In the code below I made a simple rule for the coloring just to check whether anything changes. Please ignore the minimal error handling attempt...im still pretty new at this.
Can anyone help?
Code:
Language="VBSCRIPT"
Sub CATMain()
On Error Resume Next
'*******************************************
' Initiate and selection
'*******************************************
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
If Err.Number > 0 Then
MsgBox "Active Document is not a part document!"
Else
On Error GOTO 0
Set selection1 = partDocument1.Selection
selection1.Clear
'*******************************************
' Select Features
'*******************************************
Dim strArray(0)
strArray(0) = "Thickness" 'Selection Filter
sStatus = selection1.SelectElement3(strArray, "Select Items", False, CATMultiSelTriggWhenUserValidatesSelection, False)
'********************************************
' Define coloring scheme
'********************************************
'Create color scheme
'**********************************************
' Color the features
'**********************************************
For i = 1 To selection1.Count
'Set length = selection1.Item(i).Value.Offset
'strLength = length.Value * (-1)
'Coloring formula
R=10*i
G=0
B=10
selection1.Item(i).Value.VisProperties.SetRealColor R, G, B, 1
Next
'***********************************************
' Update the part
'***********************************************
part1.Update
End If
End Sub