def find_matching_view(dest_doc, source_view): for v in DB.FilteredElementCollector(dest_doc).OfClass(DB.View): if v.ViewType == source_view.ViewType \ and query.get_name(v) == query.get_name(source_view): if source_view.ViewType == DB.ViewType.DrawingSheet: if v.SheetNumber == source_view.SheetNumber: return v else: return v
def get_view_contents(dest_doc, source_view): view_elements = DB.FilteredElementCollector(dest_doc, source_view.Id)\ .WhereElementIsNotElementType()\ .ToElements() elements_ids = [] for element in view_elements: if (element.Category and element.Category.Name == 'Title Blocks') \ and not OPTION_SET.op_copy_titleblock: continue elif isinstance(element, DB.ScheduleSheetInstance) \ and not OPTION_SET.op_copy_schedules: continue elif isinstance(element, DB.Viewport) \ or 'ExtentElem' in query.get_name(element): continue elif isinstance(element, DB.Element) \ and element.Category \ and 'guide' in str(element.Category.Name).lower(): continue elif isinstance(element, DB.Element) \ and element.Category \ and 'views' == str(element.Category.Name).lower(): continue else: elements_ids.append(element.Id) return elements_ids
def print_view(view, prefix='', print_id=True): outstr = query.get_name(view) if print_id: outstr = PyRevitOutputWindow.linkify(view.Id) + '\t' + outstr print(prefix + outstr)