How to get the latest Revit Phase with Python? I mean the last in order of phase sequence defined in the project Revit file.
For example with this code I get all Phases in a project but I want to get just the latest, is the last item in the output list always the last Phase in sequence order defined in Revit?
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import Autodesk
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
inputdoc = UnwrapElement(IN[1])
if inputdoc == None:
doc = DocumentManager.Instance.CurrentDBDocument
elif inputdoc.GetType().ToString() == "Autodesk.Revit.DB.RevitLinkInstance":
doc = inputdoc.GetLinkDocument()
elif inputdoc.GetType().ToString() == "Autodesk.Revit.DB.Document":
doc = inputdoc
else: doc = None
elementlist = []
for phase in doc.Phases:
elementlist.append(phase.ToDSType(True))
OUT = elementlist