In a Inventor document, An Appearance is a collection of values of different types. In order to create new Appearance, respective AssetValue should be defined and values are assigned. AssetValues would be types like floats, integers, strings, Booleans. Sometimes complex AssetValue types like color, filename(image path name), textures and choices as shown in below image.
The following VBA sample code can be used to create new appearance in a PartDocument. Before running this code, a PartDocument should be opened in Inventor application.
Sub Create_New_Appearance()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oTG As TransientObjects
Set oTG = ThisApplication.TransientObjects
Dim docAsset As Assets
Set docAsset = oDoc.Assets
Dim oAppearance As Asset
Set oAppearance = docAsset.Add(kAssetTypeAppearance, "Generic", "Appearences", "New Appearence")
Dim generic_color As ColorAssetValue
Set generic_color = oAppearance.Item("generic_diffuse")
generic_color.Value = oTG.CreateColor(255, 95, 15)
generic_color.HasConnectedTexture = True
Dim generic_texture As AssetTexture
Set generic_texture = generic_color.ConnectedTexture
Dim generic_image As FilenameAssetValue
Set generic_image = generic_texture.Item("unifiedbitmap_Bitmap")
generic_image.Value = "C:\Program Files (x86)\Common Files\Autodesk Shared\Materials\Textures\2\Mats\272.png"Dim generic_image_fade As FloatAssetValue
Set generic_image_fade = oAppearance.Item("generic_diffuse_image_fade")
generic_image_fade.Value = 0.75
Dim generic_glossiness As FloatAssetValue
Set generic_glossiness = oAppearance.Item("generic_glossiness")
generic_glossiness.Value = 0.3
Dim generic_highlights As BooleanAssetValue
Set generic_highlights = oAppearance.Item("generic_is_metal")
generic_highlights.Value = False
Dim reflectivity_direct As FloatAssetValue
Set reflectivity_direct = oAppearance.Item("generic_reflectivity_at_0deg")
reflectivity_direct.Value = 0.65
Dim reflectivity_oblique As FloatAssetValue
Set reflectivity_oblique = oAppearance.Item("generic_reflectivity_at_90deg")
reflectivity_oblique.Value = 0.35
Dim transperency_amount As FloatAssetValue
Set transperency_amount = oAppearance.Item("generic_transparency")
transperency_amount.Value = 0.62
transperency_amount.HasConnectedTexture = True
Dim transperency_texture As AssetTexture
Set transperency_texture = transperency_amount.ConnectedTexture
Dim transperency_image As FilenameAssetValue
Set transperency_image = transperency_texture.Item("unifiedbitmap_Bitmap")
transperency_image.Value = "C:\Program Files (x86)\Common Files\Autodesk Shared\Materials\Textures\2\Mats\532.png"
Dim transperency_image_fade As FloatAssetValue
Set transperency_image_fade = oAppearance.Item("generic_transparency_image_fade")
transperency_image_fade.Value = 0.65
Dim transperency_transluency As FloatAssetValue
Set transperency_transluency = oAppearance.Item("generic_refraction_translucency_weight")
transperency_transluency.Value = 0.25
Dim transperency_refraction_2 As FloatAssetValue
Set transperency_refraction_2 = oAppearance.Item("generic_refraction_index")
transperency_refraction_2.Value = 1.46
'Air -> 1.00
'Water -> 1.33
'Alcohol -> 1.36
'Quartz -> 1.46
'Glass -> 1.52
'Diamond -> 2.30
'Custom -> Other than the above values
Dim cutouts_image As FloatAssetValue
Set cutouts_image = oAppearance.Item("generic_cutout_opacity")
cutouts_image.HasConnectedTexture = True
Dim cutouts_texture As AssetTexture
Set cutouts_texture = cutouts_image.ConnectedTexture
Dim cutouts_image_path As FilenameAssetValue
Set cutouts_image_path = cutouts_texture.Item("unifiedbitmap_Bitmap")
cutouts_image_path.Value = "C:\Program Files (x86)\Common Files\Autodesk Shared\Materials\Textures\2\Mats\584.png"
Dim self_illum_color As ColorAssetValue
Set self_illum_color = oAppearance.Item("generic_self_illum_filter_map")
self_illum_color.Value = oTG.CreateColor(255, 85, 75)
Dim self_illum_luminance As FloatAssetValue
Set self_illum_luminance = oAppearance.Item("generic_self_illum_luminance")
self_illum_luminance.Value = 250
'Dim Glow -> 10.00
'LED Panel -> 100.00
'LED Screen -> 140.00
'Cell phone screen -> 200.00
'CRT Television -> 250.00
'LampShade Exterior -> 1,300.00
'LampShade Interior -> 2,500.00
'Desk Lamp Lens -> 10,000.00
'Halogen Lamp Lens -> 10,000.00
'Frosted Bulb -> 210,000.00
'Custom -> Other than the above values
Dim self_illum_color_temp As FloatAssetValue
Set self_illum_color_temp = oAppearance.Item("generic_self_illum_color_temperature")
self_illum_color_temp.Value = 6000
'Candle -> 1,850.00
'Incandescent Bulb -> 2,800.00
'Flood Light -> 3,400.00
'Moon Light -> 4,100.00
'Daylight Warm -> 5,000.00
'Daylight Cool -> 6,000.00
'Xenon Arc Lamp -> 6,420.00
'TV Screen -> 9,320.00
'Custom -> Other than the above values
Dim bump_image As ColorAssetValue
Set bump_image = oAppearance.Item("generic_bump_map")
bump_image.HasConnectedTexture = True
Dim bump_texture As AssetTexture
Set bump_texture = bump_image.ConnectedTexture
Dim bump_image_path As FilenameAssetValue
Set bump_image_path = bump_texture.Item("unifiedbitmap_Bitmap")
bump_image_path.Value = "C:\Program Files (x86)\Common Files\Autodesk Shared\Materials\Textures\2\Mats\124.png"
Dim bump_amount As FloatAssetValue
Set bump_amount = oAppearance.Item("generic_bump_amount")
bump_amount.Value = 0.35
Dim tint_color As ColorAssetValue
Set tint_color = oAppearance.Item("common_Tint_color")
tint_color.Value = oTG.CreateColor(80, 85, 80)
End Sub
Please refer “Materials and Appearances” overview in the Inventor API Help for additional information on this Appearances.