Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get Space Phase

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
mcclanathan
1207 Views, 5 Replies

Get Space Phase

Hello,

I am writing a macro that will get all selected elements, delete any existing zones in the selection, remove anything else thats not a space, then create a new zone with the spaces that are left over. To create the new zone I need a phase.  I have most of the macro working, but I can't figure out how to get the phase of spaces.  I trying to do something like:


Phase phase = e.Phase;

 Can someone show me how get the phase of an element, and/or space?

Thank you

5 REPLIES 5
Message 2 of 6
jeremytammik
in reply to: mcclanathan

Dear Mcclanathan,

 

I am afraid I do not know the answer to your question off-hand.

 

Here are some avenues for further exploration, at least:

 

Background info on phases:

 

http://help.autodesk.com/view/RVT/2014/ENU/?guid=GUID-DD43AD1E-37D1-4F61-8A23-52C9DEFF2D3F

 

This also shows how to enumerate the existing phases in the project.

 

For a given element, you can find out its state relative to a given phase using the GetPhaseStatus Method and paassing in a specific phase id.

 

Here are some of the phase related properties and methods on the common Revit database element base class:

 

  • Element.CreatedPhaseId Property
  • Element.DemolishedPhaseId Property
  • Element.GetPhaseStatus Method
  • Element.IsPhaseCreatedValid Method
  • Element.IsPhaseDemolishedValid Method 

 

This post on The Building Coder explores some aspects, but not exactly what you are after:

 

http://thebuildingcoder.typepad.com/blog/2012/02/family-instance-room-phase.html

 

I hope this helps.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 6
jmcclanathan
in reply to: jeremytammik

How about getting the phase of a view?  Is that more straight forward than getting the phase of an element?

Message 4 of 6
jeremytammik
in reply to: jmcclanathan

Dear Mcclanathan,

 

I am not saying that it is not straightforward to retrieve the phase of an element, if such a thing exists at all.

 

Anyway, to answer your new question:

 

Yes, that is definitely doable.

 

I just recently discussed in on The Buildiong Coder.

 

Even more so, I discussed setting the phase of a view:

 

http://thebuildingcoder.typepad.com/blog/2014/08/setting-the-phase-of-a-view.html

 

I hope this helps.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 6
mcclanathan
in reply to: jeremytammik

I figured out a way to get the phase.  Thanks for all the help.  Here is the code I used:

View activeView = this.ActiveUIDocument.Document.ActiveView;
Parameter param = activeView.get_Parameter(BuiltInParameter.VIEW_PHASE);
ElementId eID = param.AsElementId();
Phase phase = doc.GetElement(eID) as Phase;

 

Message 6 of 6
jeremytammik
in reply to: mcclanathan

Dear Mcclanathan,

 

Thank you for the confirmation, appreciation, kudos, and sharing the sample code snippet.

 

I am glad that this is resolved!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community