Render style

Render style

dhanshri_gavas
Contributor Contributor
378 Views
3 Replies
Message 1 of 4

Render style

dhanshri_gavas
Contributor
Contributor

How can I retrieve the render style (RGB color value) from a document using an API?

 

0 Likes
379 Views
3 Replies
Replies (3)
Message 2 of 4

Michael.Navara
Advisor
Advisor

Hello @dhanshri_gavas 

RenderStyles are obsolete and is no longer supported. You need to use Assets and its AssetValues instead.

 

This simple rule prints the ActiveAppearance.AssetValues to iLogic log window. You can choose which one is important for you.

 

Dim result As New System.Text.StringBuilder()
result.AppendLine("AssetValues")
Dim part As PartDocument = ThisDoc.Document
For Each oAssetValue As AssetValue In part.ActiveAppearance
	result.AppendFormat("{1}{0}{2}{0}{3}" & vbCrLf, vbTab, oAssetValue.DisplayName, oAssetValue.Name, oAssetValue.ValueType)
Next
Logger.Debug(result.ToString)

 

 

0 Likes
Message 3 of 4

dhanshri_gavas
Contributor
Contributor

Hi @Michael.Navara 
     From the above code, I am not getting an RGB value; to be more specific, attaching the image below. Want to get that value?

dhanshri_gavas_0-1724386304209.png

dhanshri_gavas_1-1724386352689.png

Thanks in advance.

 

 

0 Likes
Message 4 of 4

Michael.Navara
Advisor
Advisor

You have to play with it. You need to look at the individual values, its type and compare the values with the UI. Here is sample how to filter asset values by its ValueType and obtain RGB values of Generic->Color and Self Illumination->Filter Color

 

Sub main
	Dim result As New System.Text.StringBuilder()
	result.AppendLine("AssetValues")
	Dim part As PartDocument = ThisDoc.Document
	For Each oAssetValue As AssetValue In part.ActiveAppearance
		If Not oAssetValue.ValueType = AssetValueTypeEnum.kAssetValueTypeColor Then Continue For

		Dim colorValue As Inventor.ColorAssetValue = oAssetValue
		Dim c As Color = colorValue.Value

		result.AppendFormat("{1}{0}{2}{0}{3}" & vbCrLf, vbTab,
		oAssetValue.DisplayName,
		oAssetValue.Name,
		ColorToString(c)
		)
	Next
	Logger.Debug(result.ToString)

	'Direct access
	Logger.Debug("Generic->Color: {0}", ColorToString(part.ActiveAppearance("generic_diffuse").Value))
	Logger.Debug("Self Illumination->Filter Color: {0}", ColorToString(part.ActiveAppearance("generic_self_illum_filter_map").Value))

End Sub

Function ColorToString(color As Color)
	Return String.Format("[{0}, {1}, {2}]", color.Red, color.Green, color.Blue)
End Function

 

 

0 Likes