Render style
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
How can I retrieve the render style (RGB color value) from a document using an API?
How can I retrieve the render style (RGB color value) from a document using an API?
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)
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?
Thanks in advance.
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