Element.CreatedPhaseId Property

ElementCreatedPhaseId Property

Id of a Phase at which the Element was created.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public ElementId CreatedPhaseId { get; set; }
Public Property CreatedPhaseId As ElementId
	Get
	Set
public:
property ElementId^ CreatedPhaseId {
	ElementId^ get ();
	void set (ElementId^ value);
}
member CreatedPhaseId : ElementId with get, set

Property Value

ElementId
Exceptions
ExceptionCondition
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.
ArgumentNullException When setting this property: A non-optional argument was null
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.
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.

Example
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

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