Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
J-Camper
in reply to: tom89Y38

@tom89Y38,

 

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.