2024 Property
Changes 0
P

Element.CreatedPhaseId

Description:
Id of a Phase at which the Element was created.
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.

public ElementId CreatedPhaseId { get; set; }
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);
    }
}