Revit 2022 API |
Element..::..CreatedPhaseId Property |
Element Class Example See Also |
Id of a Phase at which the Element was created.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 22.0.0.0 (22.1.0.0)
Since:
2013
Syntax
Remarks
After setting the property CreatedPhaseId, regeneration can fail if CreatedPhaseId and DemolishedPhaseId are out of order with respect to their index in the property Document.Phases.
When Revit is running with UI activated, the default created phase for newly created elements is inherited from the phase of the currently active view.
When Revit is running without its UI, such as when Revit runs on Autodesk Forge Design Automation API for Revit, the default CreatedPhaseId for newly created elements is the latest phase in Autodesk::Revit::DB::Document::Phases.
Examples

void ShowPhaseCreatedName(Element element) { // Get the Phase Create property, and assert it should not be null Autodesk.Revit.DB.Phase phaseCreated = element.Document.GetElement(element.CreatedPhaseId) as Phase; if (null == phaseCreated) { throw new Exception("Elements always have a phase for when they are created."); } else { // Show the Phase Create name to the user. String prompt = "The phase created is: " + phaseCreated.Name; TaskDialog.Show("Revit",prompt); } }

Private Sub ShowPhaseCreatedName(element As Element) ' Get the Phase Create property, and assert it should not be null Dim phaseCreated As Autodesk.Revit.DB.Phase = TryCast(element.Document.GetElement(element.CreatedPhaseId), Phase) If phaseCreated Is Nothing Then Throw New Exception("Elements always have a phase for when they are created.") Else ' Show the Phase Create name to the user. Dim prompt As [String] = "The phase created is: " + phaseCreated.Name TaskDialog.Show("Revit", prompt) End If End Sub
Exceptions
Exception | Condition |
---|---|
Autodesk.Revit.Exceptions..::..ArgumentException | When setting this property: The element does not allow setting the property CreatedPhaseId to the value of createdPhaseId. -or- When setting this property: Invalid order of phases: An object cannot be demolished before it was created. |
Autodesk.Revit.Exceptions..::..ArgumentNullException | When setting this property: A non-optional argument was null |
Autodesk.Revit.Exceptions..::..InvalidOperationException | When setting this property: The element does not have properties CreatedPhaseId and DemolishedPhaseId. -or- When setting this property: The element does not allow setting the properties CreatedPhaseId and DemolishedPhaseId. |