Subelement
An object that represents an element or a subelement within the Autodesk Revit project.
Inheritance Hierarchy
System.Object
Autodesk.Revit.DB.Subelement
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public class Subelement : IDisposable
The Subelement type exposes the following members.
Properties
Name
Description
Public Property
Category
Retrieves a Category object that represents the category or sub category of the subelement.
Public Property
Document
The document in which the subelement resides.
Public Property
Element
The element in which the subelement resides.
Public Property
IsValidObject
Specifies whether the .NET object represents a valid Revit entity.
Public Property
TypeId
The identifier of this subelement’s type.
Public Property
UniqueId
A stable unique identifier for this subelement within the document.
Methods
Name
Description
Public Method
CanHaveTypeAssigned
Identifies if the subelement can have a type assigned.
Public Method
ChangeTypeId
Changes the type of the subelement.
Public Method
Static Member
Create
Creates an object representing element or subelement.
Public Method
Dispose
Releases all resources used by the Subelement
Public Method
Equals
Determines whether the specified object is equal to the current object.
(Inherited from Object)
Public Method
GetAllParameters
Returns all parameters of this subelement.
Public Method
GetBoundingBox
Retrieves a box that circumscribes all geometry of the subelement.
Public Method
GetGeometryObject
Retrieve one geometric primitive representing given subelement.
Public Method
GetHashCode
Serves as the default hash function.
(Inherited from Object)
Public Method
GetParameterValue
Obtains the current parameter value of this subelement given a parameter id.
Public Method
GetReference
Obtains the reference to this subelement.
Public Method
GetType
Gets the Type of the current instance.
(Inherited from Object)
Public Method
GetValidTypes
Obtains a set of types that are valid for this subelement.
Public Method
HasParameter
Checks if this subelement have given parameter.
Public Method
IsParameterModifiable
Checks if given parameter of this subelement is modifiable.
Public Method
Static Member
IsValidSubelementReference
Checks if given Reference identifies either a valid element or subelement.
Public Method
IsValidType
Checks if given type is valid for this subelement.
Public Method
SetParameterValue
Sets a new parameter value of this subelement given a parameter id.
Public Method
ToString
Returns a string that represents the current object.
(Inherited from Object)
Remarks
Subelements provide a way for parts of an element to behave as though they were real elements without incurring the overhead of adding more full elements to the model.
Many Revit features (for example parameters, schedules, and tags) were designed to operate on Elements. As a result, the Revit code needs to represent objects as Elements for them to participate in those features. This can lead to scalability problems, because every Element adds overhead and adding many Elements may decrease the performance of the model. An alternative is to use Subelements. An element can expose a set of “Subelements” that it contains, specifying characteristics like their category and parameters, and certain Revit capabilities will treat those Subelements the same as ordinary Elements. For example, a Subelement may contribute geometry to the main element and may be able to be selected independently of its parent Element. It will possibly have its own (settable) type as well as an assigned category which can be different from its parent Element.
In the API, the new Subelement class is used to refer to either an Element or a specific subelement of a given Element. It is typically directly related to a Reference to either the Element or the specific subelement. Note that creation of new Subelements for a given element is not done generically. Instead, the given Element may provide the ability to modify it’s definition, resulting in the creation of new Subelements.
Examples of Elements which may have Subelements in practice include:
- RebarContainer
- Rebar
- FabricSheet
- Stairs elements which make up MultistoryStairs elements
- Railing
- [!:Autodesk::Revit::DB::Architecture::ContinuousRail]
To get access to a particular Subelement, you may use any of the following:
- Create(Document, Reference)
- IsValidSubelementReference(Document, Reference)
- Autodesk.Revit.DB.Document.GetSubelement(Autodesk.Revit.DB.Reference) if you have a Reference to a Subelement.
- Autodesk.Revit.DB.Document.GetSubelement(String) if you have a unique id of a Subelement.
- GetSubelements.