The ElementId of the AppearanceAssetElement.
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 21.0.0.0 (21.1.1.109)
Since: 2014
Syntax
C# |
---|
public ElementId AppearanceAssetId { get; set; } |
Visual Basic |
---|
Public Property AppearanceAssetId As ElementId Get Set |
Visual C++ |
---|
public: property ElementId^ AppearanceAssetId { ElementId^ get (); void set (ElementId^ value); } |
Field Value
The id of the AppearanceAssetElement, or InvalidElementId if the material does not have an associated appearance asset.
Remarks
This is the id to the element that contains visual material information used for rendering.
In some cases where the material is created without setting up custom render appearance properties
(for example, when the material is created via an import, or when it is created by the API),
this property will be InvalidElementId. In that situation the standard material properties such as
Color and Transparency will dictate the appearance of the material during rendering.
Examples

private void ReadMaterialAppearanceProp(Document document, Material material) { ElementId appearanceId = material.AppearanceAssetId; AppearanceAssetElement appearanceElem = document.GetElement(appearanceId) as AppearanceAssetElement; Asset theAsset = appearanceElem.GetRenderingAsset(); string libraryName = theAsset.LibraryName; string title = theAsset.Title; // The predefined asset can be empty. at this time, get the system appearance asset instead. if (theAsset.Size == 0) { IList<Asset> systemAppearanceAssets = document.Application.GetAssets(AssetType.Appearance); foreach (Asset systemAsset in systemAppearanceAssets) { if(theAsset.LibraryName == systemAsset.LibraryName && theAsset.Name == systemAsset.Name) { // Read the Asset information here. break; } } } }

Private Sub ReadMaterialAppearanceProp(document As Document, material As Material) Dim appearanceId As ElementId = material.AppearanceAssetId Dim appearanceElem As AppearanceAssetElement = TryCast(document.GetElement(appearanceId), AppearanceAssetElement) Dim theAsset As Asset = appearanceElem.GetRenderingAsset() Dim libraryName As String = theAsset.LibraryName Dim title As String = theAsset.Title ' The predefined asset can be empty. at this time, get the system appearance asset instead. If theAsset.Size = 0 Then Dim systemAppearanceAssets As IList(Of Asset) = document.Application.GetAssets(AssetType.Appearance) For Each systemAsset As Asset In systemAppearanceAssets If theAsset.LibraryName = systemAsset.LibraryName AndAlso theAsset.Name = systemAsset.Name Then ' Read the Asset information here. Exit For End If Next End If End Sub
Exceptions
Exception | Condition |
---|---|
Autodesk.Revit.Exceptions..::..ArgumentNullException | When setting this property: A non-optional argument was NULL |