Python Autodesk.Revit.DB.FilteredElementCollector() Examples
The following are 30
code examples of Autodesk.Revit.DB.FilteredElementCollector().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
Autodesk.Revit.DB
, or try the search function
.
Example #1
Source File: rps_detach_audit_qc.py From rvt_model_services with MIT License | 6 votes |
def count_import_instances(link_type): collector = Fec(doc).OfClass(Autodesk.Revit.DB.ImportInstance).ToElements() counter = 0 counter_linked = 0 counter_imported = 0 for item in collector: if item.IsLinked: counter_linked += 1 if not item.IsLinked: counter_imported += 1 if link_type == "linked": counter = counter_linked elif link_type == "imported": counter = counter_imported elif link_type == "all": counter = counter_linked + counter_imported return str(counter)
Example #2
Source File: utils.py From pyrevitplus with GNU General Public License v3.0 | 6 votes |
def fregion_id_by_name(name=None): """Get Id of Filled Region Type by Name. Loops through all types, tries to match name. If name not supplied, first type is used. If name supplied does not match, last type is used """ f_region_types = FilteredElementCollector(doc).OfClass(FilledRegionType) for fregion_type in f_region_types: fregion_name = Element.Name.GetValue(fregion_type) if not name or name.lower() == fregion_name.lower(): return fregion_type.Id # Loops through all, not found: use last else: logger.debug('Color not specified or not found.') return fregion_type.Id # @revit_transaction('Create Text') - Transaction Already Started on Chart
Example #3
Source File: rps_qc_model.py From rvt_model_services with MIT License | 6 votes |
def count_import_instances(link_type): collector = Fec(doc).OfClass(Autodesk.Revit.DB.ImportInstance).ToElements() counter = 0 counter_linked = 0 counter_imported = 0 for item in collector: if item.IsLinked: counter_linked += 1 if not item.IsLinked: counter_imported += 1 if link_type == "linked": counter = counter_linked elif link_type == "imported": counter = counter_imported elif link_type == "all": counter = counter_linked + counter_imported return str(counter)
Example #4
Source File: rps_qc_model.py From rvt_model_services with MIT License | 6 votes |
def count_view_filters_usage(usage_filter): filter_count = Fec(doc).OfClass(Autodesk.Revit.DB.FilterElement).ToElements().Count collector = Fec(doc).OfClass(Autodesk.Revit.DB.View).ToElements() used_filters = set() counter = 0 for view in collector: if not view.IsTemplate: if not view.ViewType.ToString() == "Schedule": try: view_filters = view.GetFilters() for view_filter in view_filters: used_filters.add(doc.GetElement(view_filter).Name) except: pass if usage_filter == "used": counter = len(usage_filter) elif usage_filter == "unused": counter = filter_count - len(used_filters) return str(counter)
Example #5
Source File: rps_detach_audit_qc.py From rvt_model_services with MIT License | 5 votes |
def count_class_type_elements(cls): collector = Fec(doc).OfClass(cls).WhereElementIsElementType().ToElements() return str(collector.Count)
Example #6
Source File: rps_detach_audit_qc.py From rvt_model_services with MIT License | 5 votes |
def get_pattern(pat_class, name_filter): collector = Fec(doc).OfClass(pat_class).ToElements() counter = 0 if name_filter: for pat in collector: if name_filter in pat.Name: counter += 1 return str(counter) else: return str(collector.Count)
Example #7
Source File: rps_detach_audit_qc.py From rvt_model_services with MIT License | 5 votes |
def get_unplaced_groups(): collector = Fec(doc).OfClass(Autodesk.Revit.DB.GroupType).ToElements() counter = 0 for group in collector: instances = group.Groups if instances.IsEmpty == 1: counter += 1 return str(counter)
Example #8
Source File: rps_detach_audit_qc.py From rvt_model_services with MIT License | 5 votes |
def count_raster_images(filtered, filter_paths): collector = Fec(doc).OfClass(Autodesk.Revit.DB.ImageType).ToElements() if filtered == "all": return str(collector.Count) if filtered == "non-project": counter = 0 for img in collector: for img_path in filter_paths: if img_path in img.Path: counter += 1 return str(counter)
Example #9
Source File: rps_detach_audit_qc.py From rvt_model_services with MIT License | 5 votes |
def all_detail_items(): collector = Fec(doc).OfCategory(BuiltInCategory.OST_DetailComponents).WhereElementIsNotElementType().ToElements() counter = 0 for item in collector: if item.Name != "Detail Filled Region": counter += 1 return str(counter)
Example #10
Source File: rps_detach_audit_qc.py From rvt_model_services with MIT License | 5 votes |
def count_rooms(filtered): collector = Fec(doc).OfCategory(BuiltInCategory.OST_Rooms).WhereElementIsNotElementType().ToElements() counter = 0 if filtered == "all": return str(collector.Count) elif filtered == "0sqm": for room in collector: if room.Area < 0.1: counter += 1 return str(counter)
Example #11
Source File: rps_detach_audit_qc.py From rvt_model_services with MIT License | 5 votes |
def count_groups(group_type, count_type): if group_type == "model": if count_type == "types": collector = Fec(doc).OfCategory(BuiltInCategory.OST_IOSModelGroups).WhereElementIsElementType().ToElements() return str(collector.Count) elif count_type == "instances": collector = Fec(doc).OfCategory(BuiltInCategory.OST_IOSModelGroups).WhereElementIsNotElementType().ToElements() return str(collector.Count) if group_type == "detail": if count_type == "types": collector = Fec(doc).OfCategory(BuiltInCategory.OST_IOSDetailGroups).WhereElementIsElementType().ToElements() return str(collector.Count) elif count_type == "instances": collector = Fec(doc).OfCategory(BuiltInCategory.OST_IOSDetailGroups).WhereElementIsNotElementType().ToElements() return str(collector.Count)
Example #12
Source File: rps_detach_audit_qc.py From rvt_model_services with MIT License | 5 votes |
def count_category_elements(category): collector = Fec(doc).OfCategory(category).WhereElementIsNotElementType().ToElements() return str(collector.Count)
Example #13
Source File: rps_detach_audit_qc.py From rvt_model_services with MIT License | 5 votes |
def count_class_elements(cls): collector = Fec(doc).OfClass(cls).WhereElementIsNotElementType().ToElements() return str(collector.Count)
Example #14
Source File: rps_detach_audit_qc.py From rvt_model_services with MIT License | 5 votes |
def count_fonts(): fonts = set() collector = Fec(doc).OfCategory(BuiltInCategory.OST_TextNotes).WhereElementIsNotElementType().ToElements() for txt in collector: fonts.add(txt.Symbol.LookupParameter("Text Font").AsString()) return str(len(fonts))
Example #15
Source File: rps_detach_audit_qc.py From rvt_model_services with MIT License | 5 votes |
def sum_sqm(category): total_area = 0.0 collector = Fec(doc).OfCategory(category).WhereElementIsNotElementType().ToElements() for area_elem in collector: total_area += area_elem.Area return str(total_area / sqft_sqm)
Example #16
Source File: HowTo_GetPhaseByName.py From revitapidocs.code with MIT License | 5 votes |
def get_phase_by_name(phase_name): phase_collector = FilteredElementCollector(doc).OfClass(Phase) for phase in phase_collector: if phase.Name.Equals(phase_name): return phase
Example #17
Source File: Tools_MakeFloorFromRooms.py From revitapidocs.code with MIT License | 5 votes |
def get_floor_types(): types = {} # {'name':'id'} floor_types = FilteredElementCollector(doc).OfCategory( BuiltInCategory.OST_Floors ).WhereElementIsElementType() for floor_type in floor_types: types[Element.Name.GetValue(floor_type)] = floor_type.Id return types
Example #18
Source File: HowTo_GetAllElementsOfCategory.py From revitapidocs.code with MIT License | 5 votes |
def all_elements_of_category(category): return FilteredElementCollector(doc).OfCategory(category).WhereElementIsNotElementType().ToElements() #All Elements Of Walls Category.
Example #19
Source File: HowTo_CreateDraftingView.py From revitapidocs.code with MIT License | 5 votes |
def get_drafting_type_id(): """Selects First available ViewType that Matches Drafting Type.""" viewfamily_types = FilteredElementCollector(doc).OfClass(ViewFamilyType) for i in viewfamily_types: if i.ViewFamily == ViewFamily.Drafting: return i.Id
Example #20
Source File: HowTo_GetFilledRegionByName.py From revitapidocs.code with MIT License | 5 votes |
def fregion_id_by_name(name=None): """Get Id of Filled Region Type by Name. Loops through all types, tries to match name. If name not supplied, first type is used. If name supplied does not match any existing types, last type is used """ f_region_types = FilteredElementCollector(doc).OfClass(FilledRegionType) for fregion_type in f_region_types: fregion_name = Element.Name.GetValue(fregion_type) if not name or name.lower() == fregion_name.lower(): return fregion_type.Id # Loops through all, not found: use last else: print('Color not specified or not found.') return fregion_type.Id
Example #21
Source File: rpshttpserver.py From rps-sample-scripts with MIT License | 5 votes |
def get_schedules(args, uiApplication): '''add code to get a specific schedule by name here''' print 'inside get_schedules...' from Autodesk.Revit.DB import ViewSchedule from Autodesk.Revit.DB import FilteredElementCollector from Autodesk.Revit.DB import ViewScheduleExportOptions import tempfile, os, urllib doc = uiApplication.ActiveUIDocument.Document collector = FilteredElementCollector(doc).OfClass(ViewSchedule) schedules = {vs.Name: vs for vs in list(collector)} if len(args): # export a single schedule schedule_name = urllib.unquote(args[0]) if not schedule_name.lower().endswith('.csv'): return 302, None, schedule_name + '.csv' schedule_name = schedule_name[:-4] if not schedule_name in schedules.keys(): return 404, 'text/plain', 'Schedule not found: %s' % schedule_name schedule = schedules[schedule_name] fd, fpath = tempfile.mkstemp(suffix='.csv') os.close(fd) dname, fname = os.path.split(fpath) opt = ViewScheduleExportOptions() opt.FieldDelimiter = ', ' schedule.Export(dname, fname, opt) with open(fpath, 'r') as csv: result = csv.read() os.unlink(fpath) return 200, 'text/csv', result else: return 200, 'text/plain', '\n'.join(schedules.keys())
Example #22
Source File: rps_qc_model.py From rvt_model_services with MIT License | 5 votes |
def all_detail_items(): collector = Fec(doc).OfCategory(BuiltInCategory.OST_DetailComponents).WhereElementIsNotElementType().ToElements() counter = 0 for item in collector: if item.Name != "Detail Filled Region": counter += 1 return str(counter)
Example #23
Source File: utils.py From pyrevitplus with GNU General Public License v3.0 | 5 votes |
def create_drafting_view(name=None): """Create a Drafting View""" def get_drafting_type_id(): """Selects First available ViewType that Matches Drafting Type.""" viewfamily_types = FilteredElementCollector(doc).OfClass(ViewFamilyType) for i in viewfamily_types: if i.ViewFamily == ViewFamily.Drafting: return i.Id drafting_type_id = get_drafting_type_id() drafting_view = ViewDrafting.Create(doc, drafting_type_id) if name is not None: drafting_view.Name = name return drafting_view
Example #24
Source File: rps_qc_model.py From rvt_model_services with MIT License | 5 votes |
def count_views(view_type): collector = Fec(doc).OfClass(Autodesk.Revit.DB.View).ToElements() counter = 0 for view in collector: if not view.IsTemplate: if view.ViewType.ToString() == view_type: counter += 1 return str(counter)
Example #25
Source File: rps_qc_model.py From rvt_model_services with MIT License | 5 votes |
def count_templateless_plan_views(): plan_view_types = ["AreaPlan", "CeilingPlan", "Detail", "DraftingView", "Elevation", "FloorPlan", "Section"] collector = Fec(doc).OfClass(Autodesk.Revit.DB.View).ToElements() counter = 0 for view in collector: if not view.IsTemplate: if view.ViewType.ToString() in plan_view_types: if view.ViewTemplateId.IntegerValue == -1: counter += 1 return str(counter)
Example #26
Source File: rps_qc_model.py From rvt_model_services with MIT License | 5 votes |
def count_fonts(): fonts = set() collector = Fec(doc).OfCategory(BuiltInCategory.OST_TextNotes).WhereElementIsNotElementType().ToElements() for txt in collector: fonts.add(txt.Symbol.LookupParameter("Text Font").AsString()) return str(len(fonts))
Example #27
Source File: rps_qc_model.py From rvt_model_services with MIT License | 5 votes |
def count_non_project_dwg_links(filter_paths): counter = 0 collector = Fec(doc).OfClass(Autodesk.Revit.DB.ImportInstance).ToElements() for inst in collector: if inst.IsLinked: inst_path = ModelPathUtils.ConvertModelPathToUserVisiblePath(doc.GetElement(inst.GetTypeId()).GetExternalFileReference().GetAbsolutePath()) for img_path in filter_paths: if img_path in inst_path: counter += 1 return str(counter)
Example #28
Source File: rps_qc_model.py From rvt_model_services with MIT License | 5 votes |
def get_unplaced_groups(): collector = Fec(doc).OfClass(Autodesk.Revit.DB.GroupType).ToElements() counter = 0 for group in collector: instances = group.Groups if instances.IsEmpty == 1: counter += 1 return str(counter)
Example #29
Source File: rps_qc_model.py From rvt_model_services with MIT License | 5 votes |
def count_raster_images(filtered, filter_paths): collector = Fec(doc).OfClass(Autodesk.Revit.DB.ImageType).ToElements() if filtered == "all": return str(collector.Count) if filtered == "non-project": counter = 0 for img in collector: for img_path in filter_paths: if img_path in img.Path: counter += 1 return str(counter)
Example #30
Source File: rps_detach_audit_qc.py From rvt_model_services with MIT License | 5 votes |
def count_non_project_dwg_links(filter_paths): counter = 0 collector = Fec(doc).OfClass(Autodesk.Revit.DB.ImportInstance).ToElements() for inst in collector: if inst.IsLinked: inst_path = ModelPathUtils.ConvertModelPathToUserVisiblePath(doc.GetElement(inst.GetTypeId()).GetExternalFileReference().GetAbsolutePath()) for img_path in filter_paths: if img_path in inst_path: counter += 1 return str(counter)