Hi,
I wrote an iLogic rule to collect data from an assembly that's very useful to my colleagues on the shop floor.
One of the functions of the rule is to create an overview like this, it checks all the appearances, and overrides, sums the surface area's and weights, etc..
Example assembly (contains sub assembly, 1 weld assembly with color override, 1 weld assembly without color override, 1 part)
The problem i'm facing: when a weld assembly has a color override, the thumbnail does not have the correct color. (This is normal because the color is given at a higher level).
Therefore I was thinking to have a work around and get the RGB value of the active appearance of that color override and color the corresponding Excel cell.
I just can't figure out how to get the RGB color values of the active appearance on a correct way.
In my code I'm already looping through all component occurrences like this
Sub ProcessWeldAssembliesWithOverrides(oAssembly As AssemblyDocument) 'subprogramma
' Loop door de alle componenten in de assembly
For Each oComp As ComponentOccurrence In oAssembly.ComponentDefinition.Occurrences
So it would be great if I could get the RGB values of oComp in that same loop.
Any ideas to help me out?
Thanks!
Solved! Go to Solution.
Solved by J-Camper. Go to Solution.
ComponentOccurrence Objects have an Appearance Property which should give you the asset at assembly level instead of part level. Then once you have that asset, you can use something like this to extract the color:
Dim CurrentAppearance As Asset = ThisDoc.Document.ActiveAppearance
For Each value As AssetValue In CurrentAppearance
If value.ValueType <> AssetValueTypeEnum.kAssetValueTypeColor Then Continue For
Dim MessageTitle As String = CurrentAppearance.DisplayName & ": " & value.DisplayName
Dim ColorVlaue As ColorAssetValue = value
Dim messageText As String = ""
If ColorVlaue.HasMultipleValues
For Each c As Color In ColorVlaue.Values
If messageText <> "" Then messageText = messageText & vbCrLf
messageText = messageText & String.Format("Red: {0} | Green: {1} | Blue: {2} | Opacity: {3}", c.Red, c.Green, c.Blue, c.Opacity).ToString
Next
Else
messageText = String.Format("Red: {0} | Green: {1} | Blue: {2} | Opacity: {3}", ColorVlaue.Value.Red, ColorVlaue.Value.Green, ColorVlaue.Value.Blue, ColorVlaue.Value.Opacity).ToString
End If
MessageBox.Show(messageText, MessageTitle)
Next
Example code above is to be run in a part file, but CurrentAsset can be set to oComp.Appearance.
Can't find what you're looking for? Ask the community or share your knowledge.