& Construction

Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
& Manufacturing

Professional CAD/CAM tools built on Inventor and AutoCAD
Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
Professional CAD/CAM tools built on Inventor and AutoCAD
Hi all,
When creating generic appearance from sample code:
Public Sub CreateSimpleColorAppearance() Dim doc As Document Set doc = ThisApplication.ActiveDocument ' Only document appearances can be edited, so that's what's created. ' This assumes a part or assembly document is active. Dim docAssets As Assets Set docAssets = doc.Assets ' Create a new appearance asset. Dim appearance As Asset Set appearance = docAssets.Add(kAssetTypeAppearance, "Generic", _ "MyShinyRed", "My Shiny Red Color") Dim tobjs As TransientObjects Set tobjs = ThisApplication.TransientObjects Dim color As ColorAssetValue Set color = appearance.Item("generic_diffuse") color.value = tobjs.CreateColor(255, 15, 15) Dim floatValue As FloatAssetValue Set floatValue = appearance.Item("generic_reflectivity_at_0deg") floatValue.value = 0.5 Set floatValue = appearance.Item("generic_reflectivity_at_90deg") floatValue.value = 0.5 End Sub
The appearance preview pic in Appearance Browser seems to be ok.
If I make e.g. Plastic Material based on code as followes:
Public Sub CreateSimpleColorAppearance_plastic()
Dim doc As Document
Set doc = ThisApplication.ActiveDocument
' Only document appearances can be edited, so that's what's created.
' This assumes a part or assembly document is active.
Dim docAssets As Assets
Set docAssets = doc.Assets
' Create a new appearance asset.
Dim appearance As Asset
Set appearance = docAssets.Add(kAssetTypeAppearance, "Plastic", _
"MyShinyRed_Plastic", "My Shiny Red Color_Plastic")
Dim tobjs As TransientObjects
Set tobjs = ThisApplication.TransientObjects
Dim color As ColorAssetValue
Set color = appearance.Item("plasticvinyl_color")
color.value = tobjs.CreateColor(255, 15, 15)
End Sub
Now the preview pic is about the white, but if start the editor for the appearance preview pic will update ok. Strange.
It seems that other appearance types do not update the preview pic correctly.
Does anyone managed to have correctly created preview pics when creating appearances through API?
/matti
Appearance Browser Pic:
Appearance Editor Pic
I see there has been no reply to this post but I have been trying to run this same sample program on Inventor 2018 and the program makes it to the "Set appearance =docAssets.Add(kAssetTypeAppearance…. line before it kicks out a "Run-time error '5': Invalid procedure call or argument message.
I have tried changing the syntax and other fixes and have searched for a solution but to no avail.
It seems to have something to do with the Set command and many of the other sample problems in the API Reference manual seem to have a similar problem.
Is there any way to get around this and make this program work?
Also can an illogic version of this program be made. What would it look like?
I just stumbled upon the same problem in Inventor 2023. Still no solution? All Appearences created by code look the same, although they have different colors:
Addition: 2023.2 Build 271
This is a bug. The thumbnail is not updated until you manually go into the appearance and hit the Apply Button.
Maybe @chandra.shekar.g or @MjDeck might Kindly look into this.
Before:
Make Any Change such as changing the Scene or switching a toggle and hit apply.
After:
Dim doc As Document = ThisApplication.ActiveDocument
' Only document appearances can be edited, so that's what's created.
' This assumes a part or assembly document is active.
Dim docAssets As Assets = doc.Assets
' Create a new appearance asset.
Dim appearance As Asset = docAssets.Add(AssetTypeEnum.kAssetTypeAppearance, "Plastic", _
"MyShinyRed_Plastic1", "My Shiny Red Color_Plastic1")
Dim tobjs As TransientObjects = ThisApplication.TransientObjects
Dim color As ColorAssetValue = appearance.Item("plasticvinyl_color")
color.Value = tobjs.CreateColor(255, 15, 15)
@A.Acheson schrieb:This is a bug. The thumbnail is not updated until you manually go into the appearance and hit the Apply Button.
Yes, I have observed that behavior as well. But I don't want to manually edit >200 appearances one by one.
This bug has been around for years and Autodesk doesn't seem to care.
Regards
Christoph
@c_hoppen and @A.Acheson , thanks for the reminder. Sorry about our delay in looking at it. This is internal issue INVGEN-66589. I think we can fix it soon.
Hello,
Is there a workaround in order to get the updated thumbnail showing the colour?
I just created 100+ appearances yesterday and would like the user to at least preview the colours.
Perhaps programmatically edit the asset?
How to buy
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © 2025 Autodesk Inc. All rights reserved
Type a product name