Asset Class

Asset Class

Represents a connected property of material.
Inheritance Hierarchy

Namespace: Autodesk.Revit.DB.Visual
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public class Asset : AssetProperties
Public Class Asset
	Inherits AssetProperties
public ref class Asset : public AssetProperties
type Asset = 
    class
        inherit AssetProperties
    end

The Asset type exposes the following members.

Properties
 NameDescription
Public propertyAssetType The type of RenderingAsset
Public propertyIsReadOnly Identifies if the object is read-only or modifiable. If true, the object may not be modified. If false, the object's contents may be modified.
(Inherited from AssetProperty)
Public propertyIsValidObject Specifies whether the .NET object represents a valid Revit entity.
(Inherited from AssetProperty)
Public propertyItem
(Inherited from AssetProperties)
Public propertyLibraryName Library name
Public propertyNameGet the name of the AssetProperty
(Inherited from AssetProperty)
Public propertyNumberOfConnectedProperties The number of currently connected properties.
(Inherited from AssetProperty)
Public propertySize The number of the AssetProperty(s) in the object.
(Inherited from AssetProperties)
Public propertyTitle Asset title
Public propertyTypeReturns the type of the AssetProperty
(Inherited from AssetProperty)
Top
Methods
 NameDescription
Public methodAddConnectedAsset Adds a new connected asset attached to this asset property, if it allows it.
(Inherited from AssetProperty)
Public methodCode exampleAddCopyAsConnectedAsset Makes a copy of the asset and connects it to this property.
(Inherited from AssetProperty)
Public methodDispose
(Inherited from AssetProperty)
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Public methodFindByName Gets the property with the given name.
(Inherited from AssetProperties)
Public methodGet Gets the property at the given index.
(Inherited from AssetProperties)
Public methodGetAllConnectedProperties Gets the list of the connected properties. Connected properties are the detachable properties of an AssetProperty. e.g. diffuse property can have texture as its connected property. It can also detach texture on runtime.
(Inherited from AssetProperty)
Public methodGetConnectedProperty Gets one connected property with specified index.
(Inherited from AssetProperty)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodCode exampleGetSingleConnectedAsset Gets the single connected asset attached to this asset property, if it exists.
(Inherited from AssetProperty)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodIsEditable Check if property can be edited.
(Inherited from AssetProperty)
Public methodIsValidIndex Returns true if the provided index is valid.
(Inherited from AssetProperties)
Public methodIsValidSchemaIdentifier Check that schema name is valid
(Inherited from AssetProperty)
Public methodRemoveConnectedAsset Removes the connected asset attached to this asset property if any.
(Inherited from AssetProperty)
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Example
public void ReadAsset(Asset asset)
{
   // Get the asset name, type and library name.
   AssetType type = asset.AssetType;
   string name = asset.Name;
   string libraryName = asset.LibraryName;

   // travel the asset properties in the asset.
   for (int idx = 0; idx < asset.Size; idx++)
   {
      AssetProperty prop = asset.Get(idx);
      ReadAssetProperty(prop);
   }
}

public void ReadAssetProperty(AssetProperty prop)
{
   switch (prop.Type)
   {
      // Retrieve the value from simple type property is easy.
      // for example, retrieve bool property value.
      case AssetPropertyType.Boolean:
         AssetPropertyBoolean boolProp = prop as AssetPropertyBoolean;
         bool propValue = boolProp.Value;
         break;

      // When you retrieve the value from the data array property,
      // you may need to get which value the property stands for.
      // for example, the APT_Double44 may be a transform data.
      case AssetPropertyType.Double44:
         AssetPropertyDoubleArray4d transformProp = prop as AssetPropertyDoubleArray4d;
         IList<double> tranformValue = transformProp.GetValueAsDoubles();
         break;

      // The APT_List contains a list of sub asset properties with same type.
      case AssetPropertyType.List:
         AssetPropertyList propList = prop as AssetPropertyList;
         IList<AssetProperty> subProps = propList.GetValue();
         if (subProps.Count == 0)
            break;
         switch (subProps[0].Type)
         {
            case AssetPropertyType.Integer:
               foreach (AssetProperty subProp in subProps)
               {
                  AssetPropertyInteger intProp = subProp as AssetPropertyInteger;
                  int intValue = intProp.Value;
               }
               break;
         }
         break;

      case AssetPropertyType.Asset:
         Asset propAsset = prop as Asset;
         ReadAsset(propAsset);
         break;
      default:
         break;
   }

   // Get the connected properties.
   // please notice that the information of many texture stores here.
   if (prop.NumberOfConnectedProperties == 0)
      return;
   foreach (AssetProperty connectedProp in prop.GetAllConnectedProperties())
   {
      // Note: Usually, the connected property is an Asset.
      ReadAssetProperty(connectedProp);
   }
}
Public Sub ReadAsset(asset As Asset)
    ' Get the asset name, type and library name.
    Dim type As AssetType = asset.AssetType
    Dim name As String = asset.Name
    Dim libraryName As String = asset.LibraryName

    ' travel the asset properties in the asset.
    For idx As Integer = 0 To asset.Size - 1
    Dim prop As AssetProperty = asset.Get(idx)
    ReadAssetProperty(prop)
    Next
End Sub

Public Sub ReadAssetProperty(prop As AssetProperty)
    Select Case prop.Type
        ' Retrieve the value from simple type property is easy.
        ' for example, retrieve bool property value.
    Case AssetPropertyType.Boolean
       Dim boolProp As AssetPropertyBoolean = TryCast(prop, AssetPropertyBoolean)
       Dim propValue As Boolean = boolProp.Value
       Exit Select

            ' When you retrieve the value from the data array property,
            ' you may need to get which value the property stands for.
            ' for example, the APT_Double44 may be a transform data.
    Case AssetPropertyType.Double44
       Dim transformProp As AssetPropertyDoubleArray4d = TryCast(prop, AssetPropertyDoubleArray4d)
       Dim tranformValue As IList(Of Double) = transformProp.GetValueAsDoubles()
       Exit Select

            ' The APT_List contains a list of sub asset properties with same type.
    Case AssetPropertyType.List
       Dim propList As AssetPropertyList = TryCast(prop, AssetPropertyList)
       Dim subProps As IList(Of AssetProperty) = propList.GetValue()
       If subProps.Count = 0 Then
          Exit Select
       End If
       Select Case subProps(0).Type
          Case AssetPropertyType.Integer
             For Each subProp As AssetProperty In subProps
                Dim intProp As AssetPropertyInteger = TryCast(subProp, AssetPropertyInteger)
                Dim intValue As Integer = intProp.Value
             Next
             Exit Select
       End Select
       Exit Select

    Case AssetPropertyType.Asset
       Dim propAsset As Asset = TryCast(prop, Asset)
            ReadAsset(propAsset)
            Exit Select
        Case Else
            Exit Select
    End Select

    ' Get the connected properties.
    ' please notice that the information of many texture stores here.
    If prop.NumberOfConnectedProperties = 0 Then
        Return
    End If
    For Each connectedProp As AssetProperty In prop.GetAllConnectedProperties()
        ' Note: Usually, the connected property is an Asset.
        ReadAssetProperty(connectedProp)
    Next
End Sub

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

See Also