def ElementIntersectWith(Elements, BuiltInCategory): """ :param Elements,Any Elments for test which is Interset with: BuiltInCategory,Which Category Elements be Interseted :return [[Intersections],[Intersections],[Intersections]]: """ Final = [] for w in Elements: wBox = w.BoundingBox[curview] outLine = DB.Outline(wBox.Min, wBox.Max) boundingBoxIntersectsFilter = DB.BoundingBoxIntersectsFilter(outLine) collector = DB.FilteredElementCollector(curdoc) elements = collector.WherePasses( boundingBoxIntersectsFilter).OfCategory( BuiltInCategory).ToElements() wSolid = GetElementSolid(w) bFinal = [] for i in elements: bSolid = GetFamilyInstanceSolid(i) if len(bSolid) != 0: try: result = DB.BooleanOperationsUtils.ExecuteBooleanOperation( wSolid[0], bSolid[0], DB.BooleanOperationsType.Intersect) Volume = result.Volume except Exception as e: Volume = 0 print(e) print(i.Id) if Volume > 0.0001: #DB.JoinGeometryUtils.JoinGeometry(curdoc, w, i) bFinal.append(i) print("ID{}与ID{}相交".format(w.Id, i.Id)) else: print("ID{}没有实体".format(i.Id)) Final.append(bFinal) return Final
def set_rev_on_sheets(revision_element, sheets=None): if not sheets: # collect data sheets = DB.FilteredElementCollector(revit.doc)\ .OfCategory(DB.BuiltInCategory.OST_Sheets)\ .WhereElementIsNotElementType()\ .ToElements() affectedsheets = [] with revit.Transaction('Set Revision on Sheets'): for s in sheets: revs = list(s.GetAdditionalRevisionIds()) revs.append(revision_element.Id) s.SetAdditionalRevisionIds(List[DB.ElementId](revs)) affectedsheets.append(s) if len(affectedsheets) > 0: print('SELECTED REVISION ADDED TO THESE SHEETS:') print('-' * 100) for s in affectedsheets: snum = s.LookupParameter('Sheet Number').AsString().rjust(10) sname = s.LookupParameter('Sheet Name').AsString().ljust(50) print('NUMBER: {0} NAME:{1}'.format(snum, sname))
def PopulateIntersection(_win, _elements, _current_view, _doc): bb = _win.get_BoundingBox(_current_view) x = _win.Location.Point.X y = _win.Location.Point.Y location_pt = DB.XYZ(x, y, (bb.Max.Z + bb.Min.Z) * 0.5) if _doc.IsFamilyDocument: wall = DB.FilteredElementCollector(_doc) \ .OfCategory(DB.BuiltInCategory.OST_Walls) \ .WhereElementIsNotElementType() \ .ToElements() host_win = wall[0] else: host_win = _win.SuperComponent # The root window # host_win = _win.SuperComponent # The root window direction_up = DB.XYZ(0, 0, 1) direction_down = DB.XYZ(0, 0, -1) direction_left = _win.HandOrientation.Normalize( ) # The left will be read from outside-in direction_right = direction_left.Negate() up = FindSingleIntersection(_win, host_win, _elements, _current_view, location_pt, direction_up, _doc) down = FindSingleIntersection(_win, host_win, _elements, _current_view, location_pt, direction_down, _doc) left = FindSingleIntersection(_win, host_win, _elements, _current_view, location_pt, direction_left, _doc) right = FindSingleIntersection(_win, host_win, _elements, _current_view, location_pt, direction_right, _doc) PopulateThermalValue(_win, "up", up, _doc) PopulateThermalValue(_win, "down", down, _doc) PopulateThermalValue(_win, "left", left, _doc) PopulateThermalValue(_win, "right", right, _doc)
def remove_all_legends(): """Remove All Views (Legends only)""" cl = DB.FilteredElementCollector(revit.doc) legend_views = set(cl.OfClass(DB.View) .WhereElementIsNotElementType() .ToElements()) open_UIViews = revit.uidoc.GetOpenUIViews() open_views = [ov.ViewId.IntegerValue for ov in open_UIViews] def confirm_removal(v): if isinstance(v, DB.View) and v.ViewType == DB.ViewType.Legend: if v.ViewType in READONLY_VIEWS: return False elif v.IsTemplate: return False elif '<' in v.ViewName: return False elif v.Id.IntegerValue in open_views: return False else: return True elif isinstance(v, DB.ViewSchedule) \ and v.Definition.CategoryId == \ DB.Category.GetCategory(revit.doc, DB.BuiltInCategory.OST_KeynoteTags).Id: return True else: return False print_header('REMOVING LEGENDS') remove_action('Remove All Legends', 'Legend', legend_views, validity_func=confirm_removal)
def _ask_for_titleblock(self): no_tb_option = 'No Title Block' titleblocks = DB.FilteredElementCollector(revit.doc)\ .OfCategory(DB.BuiltInCategory.OST_TitleBlocks)\ .WhereElementIsElementType()\ .ToElements() tblock_dict = { '{}: {}'.format(tb.FamilyName, revit.ElementWrapper(tb).name): tb for tb in titleblocks } options = [no_tb_option] options.extend(tblock_dict.keys()) selected_titleblocks = forms.SelectFromList.show(options, multiselect=False) if selected_titleblocks: if no_tb_option not in selected_titleblocks: self._titleblock_id = tblock_dict[selected_titleblocks[0]].Id else: self._titleblock_id = DB.ElementId.InvalidElementId return True return False
def select_sheets(title='Select Sheets', button_name='Select', width=DEFAULT_INPUTWINDOW_WIDTH, multiple=True, filterfunc=None, doc=None): doc = doc or HOST_APP.doc all_sheets = DB.FilteredElementCollector(doc) \ .OfClass(DB.ViewSheet) \ .WhereElementIsNotElementType() \ .ToElements() if filterfunc: all_sheets = filter(filterfunc, all_sheets) # ask user for multiple sheets if multiple: return_options = \ SelectFromCheckBoxes.show( sorted([SheetOption(x) for x in all_sheets], key=lambda x: x.number), title=title, button_name=button_name, width=width) if return_options: return [x.unwrap() for x in return_options if x.state] else: return_option = \ SelectFromList.show( sorted([SheetOption(x) for x in all_sheets], key=lambda x: x.number), title=title, button_name=button_name, width=width, multiselect=False) if return_option: return return_option[0].unwrap()
def tag_all_spaces(): spaces = DB.FilteredElementCollector(revit.doc)\ .OfCategory(DB.BuiltInCategory.OST_MEPSpaces)\ .WhereElementIsNotElementType()\ .ToElements() with revit.Transaction('Tag All Spaces in All Views'): for view in views: for el in spaces: space_center = GetElementCenter(el) if not space_center: logger.debug('Can not detect center for element: {}', output.linkify(el.Id)) continue if isinstance(view, (DB.ViewSection, DB.ViewPlan)): logger.debug('Working on view: %s' % view.ViewName) space_tag = \ revit.doc.Create.NewRoomTag( DB.LinkElementId(el.Id), DB.UV(space_center.X, space_center.Y), view.Id ) if isinstance(view, DB.ViewSection): space_tag.Location.Move(DB.XYZ(0, 0, space_center.Z))
__title__ = 'List Elements of Selected Level(s)' __author__ = 'Frederic Beaupere' __context__ = 'selection' __contact__ = 'https://github.com/frederic-beaupere' __credits__ = 'http://eirannejad.github.io/pyRevit/credits/' __doc__ = 'Lists all Elements of the selected level(s).' output = script.get_output() output.print_md("####LIST ALL ELEMENTS ON SELECTED LEVEL(S):") output.print_md('By: [{}]({})'.format(__author__, __contact__)) all_elements = DB.FilteredElementCollector(revit.doc)\ .WhereElementIsNotElementType()\ .ToElements() selection = revit.get_selection() levels = [] for el in selection: if el.Category.Id.IntegerValue == int(DB.BuiltInCategory.OST_Levels): levels.append(el) if not levels: forms.alert('At least one Level element must be selected.') else: all_count = all_elements.Count print('\n' + str(all_count) + ' Elements found in project.')
"""Lists all sheets revised under any revision.""" from pyrevit import revit, DB from pyrevit import script output = script.get_output() output.print_md('**LIST OF REVISIONS:**') revs = DB.FilteredElementCollector(revit.doc)\ .OfCategory(DB.BuiltInCategory.OST_Revisions)\ .WhereElementIsNotElementType() for rev in revs: revit.report.print_revision(rev) output.print_md('*****\n\n\n###REVISED SHEETS:\n') sheetsnotsorted = DB.FilteredElementCollector(revit.doc)\ .OfCategory(DB.BuiltInCategory.OST_Sheets)\ .WhereElementIsNotElementType()\ .ToElements() sheets = sorted(sheetsnotsorted, key=lambda x: x.SheetNumber) for sht in sheets: srevs = set(sht.GetAllRevisionIds()) srevs = srevs.union(set(sht.GetAdditionalRevisionIds())) if len(srevs) > 0: revit.report.print_sheet(sht)
from pyrevit.framework import List from pyrevit import revit, DB, UI from pyrevit import forms selection = revit.get_selection() # collect all revision clouds cl = DB.FilteredElementCollector(revit.doc) revclouds = cl.OfCategory(DB.BuiltInCategory.OST_RevisionClouds)\ .WhereElementIsNotElementType() # get selected revision cloud info src_comment = None for el in selection.elements: if isinstance(el, DB.RevisionCloud): cparam = el.Parameter[DB.BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS] src_comment = cparam.AsString() # find matching clouds if src_comment: clouds = [] for revcloud in revclouds: cparam = el.Parameter[DB.BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS] dest_comment = cparam.AsString() if src_comment == dest_comment: clouds.append(revcloud.Id) # Replace revit selection with matched clouds revit.get_selection().set_to(clouds) else: forms.alert('At least one Revision Cloud must be selected.')
doc = __revit__.ActiveUIDocument.Document # make sure active view is not a sheet curview = doc.ActiveView if isinstance(curview, DB.ViewSheet): forms.alert("You're on a Sheet. Activate a model view please.", exitscript=True) target = Taggable(tag_type=DB.BuiltInCategory.OST_StructuralFramingTags, element_type=DB.BuiltInCategory.OST_StructuralFraming) selection = revit.get_selection() # collect target elements and tags in view target_tags = DB.FilteredElementCollector(revit.doc, curview.Id)\ .OfCategory(target.tag_type)\ .WhereElementIsNotElementType()\ .ToElementIds() target_elements = DB.FilteredElementCollector(revit.doc, curview.Id)\ .OfCategory(target.element_type)\ .WhereElementIsNotElementType()\ .ToElementIds() tagged_elements = [] untagged_elements = [] for eltid in target_tags: elt = revit.doc.GetElement(eltid) if elt.TaggedLocalElementId != DB.ElementId.InvalidElementId: tagged_elements.append(elt.TaggedLocalElementId.IntegerValue) dupes_id = [
'Revisions', 'Revision Clouds', 'Sheets', 'System Categories', 'System Postable Commands', 'Worksets', 'Fill Grids', ] selected_switch = \ forms.CommandSwitchWindow.show(sorted(switches), message='List elements of type:') if selected_switch == 'Graphic Styles': cl = DB.FilteredElementCollector(revit.doc) gstyles = [i for i in cl.OfClass(DB.GraphicsStyle).ToElements()] for gs in gstyles: if gs.GraphicsStyleCategory.Parent: parent = gs.GraphicsStyleCategory.Parent.Name else: parent = '---' if gs.GraphicsStyleCategory.GetHashCode() > 0: print('NAME: {0} CATEGORY:{2} PARENT: {3} ID: {1}' .format(gs.Name.ljust(50), gs.Id, gs.GraphicsStyleCategory.Name.ljust(50), parent.ljust(50))) elif selected_switch == 'Grids':
"""Show one side grid bubbles in the active view.""" from pyrevit import revit, DB __min_revit_ver__ = 2016 grids = DB.FilteredElementCollector(revit.doc)\ .OfCategory(DB.BuiltInCategory.OST_Grids)\ .WhereElementIsNotElementType().ToElements() with revit.Transaction('Show one side Grid Bubbles'): for grid in grids: try: grid.HideBubbleInView(DB.DatumEnds.End0, revit.activeview) grid.ShowBubbleInView(DB.DatumEnds.End1, revit.activeview) except Exception: pass revit.uidoc.RefreshActiveView()
from rpw.ui.forms import (FlexForm, Label, ComboBox, Separator, Button) import sys def first_digit_str(some_str): for ch in some_str: if ch.isdigit() and ch!=str(0): return ch def convert_to_internal(from_units): # convert project units to internal d_units = DB.Document.GetUnits(revit.doc).GetFormatOptions(DB.UnitType.UT_Area).DisplayUnits converted = DB.UnitUtils.ConvertToInternalUnits(from_units, d_units) return converted coll_rooms = DB.FilteredElementCollector(revit.doc).OfCategory(DB.BuiltInCategory.OST_Rooms).ToElements() # take only placed rooms good_rooms = [r for r in coll_rooms if r.Area != 0] if not good_rooms: forms.alert(msg="No rooms", sub_msg = "There are no placed rooms in model", ok=True, warn_icon=True, exitscript=True) element_parameter_set = good_rooms[0].Parameters room_params = [p.Definition.Name for p in element_parameter_set if p.StorageType.ToString() == "Double" and p.IsReadOnly == False and p.Definition.Name not in ["Limit Offset", "Base Offset"]] if not room_params: forms.alert(msg="No suitable parameter", \ sub_msg="There is no suitable parameter to use for Minimal Area Requirement. Please add a parameter 'Area Requirement' of Area Type", \
length_feet = float(forms.ask_for_string( "Enter length in meters")) / 0.3048 # sometimes revit interprets 1 > 1.0 target_parameter = DB.BuiltInParameter.CURVE_ELEM_LENGTH # FAMILY_TOP_LEVEL_PARAM, FAMILY_BASE_LEVEL_PARAM param_id = DB.ElementId(target_parameter) param_prov = DB.ParameterValueProvider(param_id) param_equality = DB.FilterNumericEquals() # equality class value_rule = DB.FilterDoubleRule(param_prov, param_equality, length_feet, 1e-3 / 0.3048) # tolerance of 1 mm param_filter = DB.ElementParameterFilter(value_rule) same_cat_elements = \ DB.FilteredElementCollector(doc,curview.Id)\ .OfCategory(DB.BuiltInCategory.OST_Walls)\ .WhereElementIsNotElementType()\ .WherePasses(param_filter)\ .ToElements() filered_elements = [] for sim_element in same_cat_elements: r_type = sim_element.GetTypeId() # if r_type == type_id: # for same family type filered_elements.append(sim_element.Id) num_walls = len(filered_elements) length_m = length_feet * 0.3048 if num_walls >= 1: revit.get_selection().set_to(filered_elements)
from pyrevit import revit, DB, forms, script output = script.get_output() paths = DB.FilteredElementCollector(revit.doc) \ .OfCategory(DB.BuiltInCategory.OST_StairsPaths) \ .WhereElementIsNotElementType() path_types = DB.FilteredElementCollector(revit.doc) \ .OfCategory(DB.BuiltInCategory.OST_StairsPaths) \ .WhereElementIsElementType() auto_paths = [p for p in paths if revit.doc.GetElement(p.GetTypeId()).StairsPathDirection == DB.Architecture.StairsPathDirection.AutomaticUpDown] up_path_id = [p.Id for p in path_types if p.StairsPathDirection == DB.Architecture.StairsPathDirection.AlwaysUp] stairs = DB.FilteredElementCollector(revit.doc) \ .OfCategory(DB.BuiltInCategory.OST_Stairs) \ .WhereElementIsNotElementType() counter = 0 with revit.Transaction("Set all Stair Paths to Up"): for a in auto_paths: a.ChangeTypeId(up_path_id[0]) counter += 1 for stair in stairs: if stair.get_Parameter(DB.BuiltInParameter.STAIRS_INST_ALWAYS_UP): stair.get_Parameter(DB.BuiltInParameter.STAIRS_INST_ALWAYS_UP).Set(1) forms.alert("Changed Stair Path direction to UP for {} stairs".format(counter))
def get_view_family_types(viewtype, doc): return [vt for vt in DB.FilteredElementCollector(doc).OfClass(DB.ViewFamilyType) if vt.ViewFamily == viewtype]
"""Get a total count and types of In Place Family in the current document. Copyright (c) 2019 Jean-Marc Couffin https://github.com/jmcouffin """ #pylint: disable=import-error,invalid-name,broad-except,superfluous-parens from pyrevit import revit, DB from pyrevit import script output = script.get_output() familyinstance_collector = DB.FilteredElementCollector(revit.doc)\ .OfClass(DB.FamilyInstance)\ .WhereElementIsNotElementType()\ .ToElements() inplace_families = [ x for x in familyinstance_collector if x.Symbol and x.Symbol.Family and x.Symbol.Family.IsInPlace ] print('Found {} in-place families'.format(len(inplace_families))) print('\nCATEGORY & FAMILY NAME') report = [] for inplace_family in inplace_families: inplace_family_type = revit.doc.GetElement(inplace_family.GetTypeId()) if inplace_family_type: category_name = inplace_family_type.Category.Name family_name = inplace_family.Symbol.Family.Name
from pyrevit.framework import List from pyrevit import revit, DB __doc__ = 'Selects all Text Note elements in the model. '\ 'This is helpful for spell checking.' textnotes = DB.FilteredElementCollector(revit.doc)\ .OfClass(DB.TextNote)\ .WhereElementIsNotElementType()\ .ToElements() selSet = [] for el in textnotes: selSet.append(el.Id) revit.get_selection().set_to(selSet)
'in dimensions as labels and also resets the value for the other ' \ 'parameters to zero or null.' logger = script.get_logger() res = \ forms.alert('Make sure your models are saved and synced. ' 'Hit OK to continue...', cancel=True) if not res == UI.TaskDialogResult.Ok: script.exit() if revit.doc.IsFamilyDocument: params = revit.doc.FamilyManager.GetParameters() dims = DB.FilteredElementCollector(revit.doc)\ .OfClass(DB.Dimension)\ .WhereElementIsNotElementType() labelParams = set() for d in dims: try: if isinstance(d.FamilyLabel, DB.FamilyParameter): labelParams.add(d.FamilyLabel.Id.IntegerValue) except Exception: continue print('STARTING CLEANUP...') with rvit.Transaction('Remove all family parameters'): for param in params: try:
translationVector = XYZ(ew, ns, elevation) translationTransform = Transform.CreateTranslation(translationVector) finalTransform = translationTransform.Multiply(rotationTransform) count = 0 outLst = [] # Just to be sure how many points will be created and each list are the same length print(len(Pointdata.pointX)) print(len(Pointdata.pointY)) print(len(Pointdata.pointZ)) # Transaction Start t = Transaction(doc, 'Add CLash Points') # Clash point Creation FSymbol = DB.FilteredElementCollector(doc) \ .OfClass(clr.GetClrType(FamilySymbol)) \ .ToElements() clashPoint = () for i in FSymbol: if i.Family.Name == 'Site-Generic-Clashpoint': clashPoint = i if not clashPoint: print('Please Load the Clash Point Family') else: t.Start() print(clashPoint.Family.Name) print(clashPoint) count = 0 elements = [] for el in Pointdata.pointX:
# make sure active view is not a sheet if isinstance(revit.active_view, DB.ViewSheet): forms.alert("You're on a Sheet. Activate a model view please.", exitscript=True) selected_switch = \ forms.CommandSwitchWindow.show( sorted(categories), message='Find undimmed elements of category:') if selected_switch: target = categories[selected_switch] selection = revit.get_selection() all_elements = DB.FilteredElementCollector(revit.doc, revit.active_view.Id)\ .OfCategory(target)\ .WhereElementIsNotElementType() all_ids = set(x.Id.IntegerValue for x in all_elements) all_dims = \ DB.FilteredElementCollector(revit.doc, revit.active_view.Id)\ .OfClass(DB.Dimension)\ .WhereElementIsNotElementType() dimmed_ids = set() for dim in all_dims: for ref in dim.References: dimmed_ids.add(ref.ElementId.IntegerValue) # find non dimmed not_dimmed_ids = all_ids.difference(dimmed_ids)
"""Lists all sheets and views that the selected elements is visible in.""" from collections import defaultdict, namedtuple from pyrevit import script from pyrevit import revit, DB __context__ = 'selection' output = script.get_output() selection = revit.get_selection() VportView = namedtuple('VportView', ['viewport', 'view']) cl_views = DB.FilteredElementCollector(revit.doc) allsheets = cl_views.OfCategory(DB.BuiltInCategory.OST_Sheets) \ .WhereElementIsNotElementType() \ .ToElements() sorted_sheets = sorted(allsheets, key=lambda x: x.SheetNumber) def find_sheeted_views(sheet): return [ VportView(revit.doc.GetElement(vp), revit.doc.GetElement(revit.doc.GetElement(vp).ViewId)) for vp in sheet.GetAllViewports() ] sheet_dict = defaultdict(list) for sheet in sorted_sheets:
from pyrevit import forms from pyrevit import revit, DB, UI from pyrevit import script logger = script.get_logger() class ViewFilterToPurge(forms.TemplateListItem): @property def name(self): return self.item.Name views = DB.FilteredElementCollector(revit.doc)\ .OfClass(DB.View)\ .WhereElementIsNotElementType()\ .ToElements() filters = DB.FilteredElementCollector(revit.doc)\ .OfClass(DB.ParameterFilterElement)\ .ToElements() usedFiltersSet = set() allFilters = set() for flt in filters: allFilters.add(flt.Id.IntegerValue) # print('{} Filters found.'.format(len(allFilters))) for v in views: if v.AreGraphicsOverridesAllowed():
def get_all_elements(doc=None): return DB.FilteredElementCollector(doc or HOST_APP.doc)\ .WhereElementIsNotElementType()\ .ToElements()
and refviewport.AsString() != '' \ or (refprefix + v.ViewName) \ in view_refs_names: continue else: print('-' * 20) print('NAME: {0}\nTYPE: {1}\nID: {2}\n' 'PLACED ON DETAIL/SHEET: {4} / {3}'.format( v.ViewName, str(v.ViewType).ljust(20), output.linkify(v.Id), sheetnum.AsString() if sheetnum else '-', detnum.AsString() if detnum else '-')) views = DB.FilteredElementCollector(revit.doc)\ .OfCategory(DB.BuiltInCategory.OST_Views)\ .WhereElementIsNotElementType()\ .ToElements() view_refs = DB.FilteredElementCollector(revit.doc)\ .OfCategory(DB.BuiltInCategory.OST_ReferenceViewer)\ .WhereElementIsNotElementType()\ .ToElements() view_refs_names = set() for view_ref in view_refs: ref_param = \ view_ref.Parameter[DB.BuiltInParameter.REFERENCE_VIEWER_TARGET_VIEW] view_refs_names.add(ref_param.AsValueString()) dviews = [] mviews = []
#pylint: disable=E0401,C0103 from pyrevit import revit, DB from pyrevit import script output = script.get_output() __context__ = 'selection' __doc__ = 'Find all Rooms/Areas/Spaces with identical names to the select '\ 'room, area or space and calculates the average area '\ 'of that space type.' areas = DB.FilteredElementCollector(revit.doc)\ .OfCategory(DB.BuiltInCategory.OST_Areas)\ .WhereElementIsNotElementType().ToElements() rms = DB.FilteredElementCollector(revit.doc)\ .OfCategory(DB.BuiltInCategory.OST_Rooms)\ .WhereElementIsNotElementType().ToElements() spaces = DB.FilteredElementCollector(revit.doc)\ .OfCategory(DB.BuiltInCategory.OST_MEPSpaces)\ .WhereElementIsNotElementType().ToElements() processed_items = { DB.Area: [], DB.Architecture.Room: [], DB.Mechanical.Space: [] } selection = revit.get_selection()
from pyrevit import revit, DB __doc__ = 'Sometimes when a revision cloud is placed inside a view '\ '(instead of a sheet) and the view is placed on a sheet, '\ 'the revision schedule on the sheet does not get updated '\ 'with the revision number of the cloud inside the sheeted view. '\ 'This script verifies that the sheet revision schedule is '\ 'actually listing all the revisions shown inside '\ 'the views of that sheet.' # Collecting all revisions revclouds = DB.FilteredElementCollector(revit.doc)\ .OfCategory(DB.BuiltInCategory.OST_RevisionClouds)\ .WhereElementIsNotElementType() # Collecting all sheets shts = DB.FilteredElementCollector(revit.doc)\ .OfCategory(DB.BuiltInCategory.OST_Sheets)\ .WhereElementIsNotElementType()\ .ToElements() sheets = sorted(shts, key=lambda x: x.SheetNumber) # make a dictionary of all viewports on each sheet sheetvpdict = {sh.Id.IntegerValue: [revit.doc.GetElement(x).ViewId for x in sh.GetAllViewports()] for sh in sheets} # make a dictionary of all revisions and the associated sheets
for id in all_ids: el = revit.doc.GetElement(id) if isinstance(el, DB.Sketch): profile = el.Profile # formatting: iterate through sketch curve arrays and gather curves if not profile: return else: for curve_arr in profile: for curve in curve_arr: curves.append(curve) return List[DB.Curve](curves) # format wall types dict for ui window coll_wt = DB.FilteredElementCollector(revit.doc).OfClass(DB.WallType) filtered_types = [wt for wt in coll_wt if wt.Kind == DB.WallKind.Basic] wall_type_dict = { ft.get_Parameter(DB.BuiltInParameter.ALL_MODEL_TYPE_NAME).AsString(): ft for ft in filtered_types } # format document phases dict for ui window doc_phases_dict = {ph.Name: ph for ph in revit.doc.Phases} # rwp UI: pick wall type and phase components = [ Label("Select Wall Type:"), ComboBox("combobox1", wall_type_dict), Label("Select Phase:"), ComboBox("combobox2", doc_phases_dict),
# -*- coding: utf-8 -*- """Duplicate selected sheets. """ __title__ = 'Duplicate\n Sheet' __author__ = "nWn" # Import from pyrevit import revit, DB from pyrevit import script from pyrevit import forms # Store current document into variable doc = __revit__.ActiveUIDocument.Document uidoc = __revit__.ActiveUIDocument # Collects all sheets in current document sheetsCollector = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_Sheets) sheets = [s for s in sheetsCollector if s.IsPlaceholder == False]