Message 1 of 3
set Schedule Filter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've duplicated a schedule with come code, but now i would like to change a filter in the schedule that filters by a shared parameter. IE shared parameter "Unit #" equals "//user input"
Ive search up and down the REVITSDK schedule creation sample. But, i cant figure it out from there.
Thanks!
public void UnitCopy() { Document doc = this.ActiveUIDocument.Document; // Filter views that match the required criteria FilteredElementCollector collector = new FilteredElementCollector(doc) .OfClass(typeof(ViewSchedule)); // Get the specific view(s) IEnumerable<ViewSchedule> views = from Autodesk.Revit.DB.ViewSchedule f in collector where (f.ViewType == ViewType.Schedule && f.ViewName.Equals("Unit Default")) select f; using (Transaction trans = new Transaction(doc, "ViewDuplicate")) { trans.Start(); foreach (ViewSchedule vw in views) { // Duplicate the existing ViewPlan view ViewSchedule newView = doc.GetElement(vw.Duplicate(ViewDuplicateOption.Duplicate)) as ViewSchedule; // Assign the desired name if (null != newView) newView.ViewName = "MyViewName";//to be user input later. // this is just my attempt. string sfield = "Unit #"; ScheduleField unit = newView.Definition.GetField(fieldId); if (unit.ParameterId == new ElementId(BuiltInParameter.SCHEDULE_FIELDS_PARAM)) { ScheduleFilter filter = new ScheduleFilter(unit.FieldId, ScheduleFilterType.Equal, sfield); newView.Definition.AddFilter(filter); }