Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've tried this a couple of different ways but none seem to do what I'm wanting (honestly all of the phase filtering I've tried seems to do nothing).
Given this code to gather the phase of the current active view.
Application app = commandData.Application.Application;
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
//variables we need
Autodesk.Revit.DB.View currentView = doc.ActiveView;
//to find out what things are 'new' we have to get the phase of the view.
Parameter phaseParam = currentView.get_Parameter(BuiltInParameter.VIEW_PHASE); //get the parameter from the view
ElementId phaseID = phaseParam.AsElementId(); //what is that id
Phase phase = doc.GetElement(phaseID) as Phase; //ok get the Phase of that thing
string phaseName = phase.Name; //now set this string to that.
I'm using this code to get a list of the doors that are created in the same phase as the active view:
public static List<FamilyInstance> GetParentDoorsPhase(Document doc, ElementId phaseID)
{
//ParameterValueProvider pvp = new ParameterValueProvider(new ElementId((int)BuiltInParameter.PHASE_CREATED));
//FilterElementIdRule rule = new FilterElementIdRule(pvp,new FilterNumericEquals(), phaseID);
//ElementParameterFilter filter = new ElementParameterFilter(rule);
List<FamilyInstance> ret = new FilteredElementCollector(doc, doc.ActiveView.Id)
.OfCategory(BuiltInCategory.OST_Doors) //get all the doors
.OfClass(typeof(FamilyInstance)) //just the instances
//.WherePasses(filter)
.Cast<FamilyInstance>()
.Where(q => q.Symbol.FamilyName.StartsWith("DOOR_") && q.CreatedPhaseId == phaseID) //where the family name starts with "DOOR_"
.ToList(); //turn this collector into a list
return ret;
}
But in testing, it returns a list of all doors in the view that start with "DOOR_". I've also attempted using a ElementParameterFilter that didn't appear to filter out items based on phase.
Any useful help would be greatly appreciated. As you can tell based on all the comments in my code, this isn't my normal skillset.
Tom
Solved! Go to Solution.