06-18-2024
12:32 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
06-18-2024
12:32 PM
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.