Revit API view current phase

Revit API view current phase

Anonymous
Not applicable
1,905 Views
1 Reply
Message 1 of 2

Revit API view current phase

Anonymous
Not applicable

Hi,

 

I'm attempting to get access to my view's current phase via the API to compare the current phase to the phase created of the elements in that view. I.m having trouble accessing the phase of the view or floor plan. I've checked out and used several previous posts on this forum and have had no success.

 

Here's my code for trying to access the view's current phase.

 

View active = commandData.Application.ActiveUIDocument.ActiveGraphicalView;
string currentPhaseId = active.get_Parameter(BuiltInParameter.VIEW_PHASE).AsString();

 

Thanks in advance!

0 Likes
Accepted solutions (1)
1,906 Views
1 Reply
Reply (1)
Message 2 of 2

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @Anonymous ,

try using this code

 View v = doc.ActiveView;

                //current phase
                  Parameter viewPhase = v.get_Parameter(BuiltInParameter.VIEW_PHASE);
                  string currentPhaseName = viewPhase.AsValueString();

               //phase created (element's created phase)                
                 Element e ;
                 Phase phaseCreated = e.Document.GetElement(e.CreatedPhaseId) as Phase;  

                if(currentPhaseName==phaseCreated.Name)
                {
                    //DO YOUR CODE
                }

I hope this helps

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network