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
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
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:
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
How about getting the phase of a view? Is that more straight forward than getting the phase of an element?
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
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;
Dear Mcclanathan,
Thank you for the confirmation, appreciation, kudos, and sharing the sample code snippet.
I am glad that this is resolved!
Cheers,
Jeremy