def main(): cl_sheets = FilteredElementCollector(doc) levels_all = cl_sheets.OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements() options = [] for l in levels_all: cb = CheckBoxLevel(l) options.append(cb) if len(options) == 0: print("Levels wasn't found") return selected1 = SelectFromCheckBoxes.show(options, title='Select levels to delete', width=300, button_name='OK') if not selected1: print("Nothing selected") return selected_levels1 = [c.level for c in selected1 if c.state == True] options = [c for c in selected1 if c.state != True] # print(selected_levels1) selected2 = SelectFromList.show(options, title='Select target level', width=300, button_name='OK') if len(options) == 0: print("You selected all levels") return if not selected2: print("Nothing selected") return print(selected2) selected_levels2 = [c.level for c in selected2] target_level = selected_levels2[0] errors = set() changed = set() for l in selected_levels1: objects_to_change = [] t = Transaction(doc, "Check level " + l.Name) t.Start() elements = doc.Delete(l.Id) t.RollBack() errors_, changed_ = LevelChangePreselected(elements, target_level.Id) errors = errors.union(set(errors_)) changed = changed.union(set(changed_)) if errors: print("Errors") print( ",".join(list(errors))) if changed: print("\nChanged") print( ",".join(list(changed)))
def _ask_for_titleblock(self): no_tb_option = 'No Title Block' titleblocks = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_TitleBlocks) \ .WhereElementIsElementType().ToElements() tblock_dict = {Element.Name.GetValue(tb): tb for tb in titleblocks} options = [no_tb_option] options.extend(tblock_dict.keys()) selected_titleblocks = 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 = ElementId.InvalidElementId return True return False
doc.LoadFamily(fam_doc_path, ret_ref) loaded_fam = ret_ref.Value # get the symbols from the original for sym_id in loaded_fam.GetFamilySymbolIds(): fam_sym = doc.GetElement(sym_id) fam_sym_name = Element.Name.GetValue(fam_sym) sortable_sym = SmartSortableFamilyType(fam_sym_name) logger.debug('Importable Type: {}'.format(sortable_sym)) symbol_list.add(sortable_sym) # okay. we have all the symbols. now rollback all the changes t.RollBack() # ask user for required symbol and load into current document ---------------------------------------------------------- options = sorted(symbol_list - loaded_symbols) if options: selected_symbols = SelectFromList.show(options) logger.debug('Selected symbols are: {}'.format(selected_symbols)) if selected_symbols: with Transaction(doc, 'Loaded family type') as t: t.Start() try: for symbol in selected_symbols: logger.debug('Loading symbol: {}'.format(symbol)) doc.LoadFamilySymbol(fam_doc_path, symbol.type_name) t.Commit() logger.debug('Successfully loaded all selected symbols') except Exception as load_err: logger.error('Error loading family symbol from {} | {}'.format( fam_doc_path, load_err)) t.RollBack() else:
clear_after_rollback=True): linked_element_ids = doc.Delete(self._rvt_type.Id) return linked_element_ids # Collect viewport types ----------------------------------------------------------------------------------------------- all_element_types = Fec(doc).OfClass(clr.GetClrType(ElementType)).ToElements() all_viewport_types = [ ViewPortType(x) for x in all_element_types if x.FamilyName == 'Viewport' ] logger.debug('Viewport types: {}'.format(all_viewport_types)) # Ask user for viewport types to be purged ----------------------------------------------------------------------------- purge_vp_types = SelectFromList.show(sorted(all_viewport_types), title='Select Types to be Converted') if not purge_vp_types: sys.exit() for purged_vp_type in purge_vp_types: logger.debug('Viewport type to be purged: {}'.format(repr(purged_vp_type))) # Ask user for replacement viewport type ------------------------------------------------------------------------------- dest_vp_types = SelectFromList.show(sorted( [x for x in all_viewport_types if x not in purge_vp_types]), multiselect=False, title='Select Replacement Type') if len(dest_vp_types) >= 1: dest_vp_typeid = dest_vp_types[0].get_rvt_obj().Id
viewlist.append(view) elif view.ViewType == ViewType.ThreeD: viewlist.append(view) elif view.ViewType == ViewType.EngineeringPlan: viewlist.append(view) elif view.ViewType == ViewType.Section: viewlist.append(view) elif view.ViewType == ViewType.Detail: viewlist.append(view) elif view.ViewType == ViewType.DraftingView: viewlist.append(view) ids = [] options = sorted(getNames(viewlist)) + sorted(getNames(templatelist)) if options: selected_fromlist = SelectFromList.show(options) logger.debug('Selected symbols are: {}'.format(selected_fromlist)) if selected_fromlist: for item in selected_fromlist: for v in viewlist: if item == v.Name: views.append(v) for t in templatelist: if item == t.Name: views.append(t) #TaskDialog.Show('pyRevit', 'Appended T to views.') else: TaskDialog.Show('pyRevit', 'Unable to execute application.') else: TaskDialog.Show('pyRevit', 'You must select one item')
for e in z_element: z_elementname.append(e.SheetNumber + " - " + e.Name) return z_elementname cl_sheets = FilteredElementCollector(doc) allsheets = cl_sheets.OfCategory( BuiltInCategory.OST_Sheets).WhereElementIsNotElementType().ToElements() sheetsexport = [] ids = [] #get visually pretty names for lookup options = sorted(getNames(allsheets)) if options: sheetsexportpretty = SelectFromList.show(options, "Select Relevant Sheets:") logger.debug('Selected sheets are: {}'.format(sheetsexportpretty)) else: TaskDialog.Show('pyRevit', 'You must select one item') sys.exit() #find the ones you wanted from the list above for sheet in allsheets: for sheetprettyprint in sheetsexportpretty: if getNames([sheet])[0] in sheetprettyprint: sheetsexport.append([sheet.SheetNumber, sheet.Name]) sheetsexport = sorted(sheetsexport, key=lambda tup: tup[0]) if not os.path.exists("c:\\temp\\"): os.mkdir("c:\\temp\\") try:
if return_options: selected = [x.unwrap() for x in return_options if x.state] viewTemplates = list(selected) #select scope box #options = ["None"] scopeBoxes = FilteredElementCollector(doc).OfCategory( BuiltInCategory.OST_VolumeOfInterest).ToElements() options = ["No Scope Box"] ## how to implement this selected = [] return_options = SelectFromList.show( [[x.Name, x] for x in scopeBoxes], title="Select Scope Box to Apply to New Views", button_name="Select", width=800) if return_options: selected = [x for x in return_options] scopeBox = selected[0][1] print str(scopeBox.Id) + " : " + scopeBox.Name levels = FilteredElementCollector(doc).OfClass(Level).ToElements() viewFamilyTypes = FilteredElementCollector(doc).OfClass( ViewFamilyType).ToElements() #create Floor Plan Views for each Level and View Template
# filteredresults = list(filteredresults) return [alloverrides, alloverrideelements] cl_dims = FilteredElementCollector(doc) alldims = cl_dims.OfCategory(BuiltInCategory.OST_Dimensions ).WhereElementIsNotElementType().ToElements() selectedoverride = [] ids = [] getValueResults = getValues(alldims) options = sorted(getValueResults[0]) referenceelements = getValueResults[1] if options: selectedoverride = SelectFromList.show(options, "Select Override to Apply:") if len(selectedoverride) == 1: #paste selected overrides print getValueResults[1] print selectedoverride #get full overrides for dimension that was selected: referenceelement = referenceelements[getValueResults[0].index( selectedoverride[0])] else: TaskDialog.Show('pyRevit', 'You must select one override only') sys.exit() print referenceelement.Below + referenceelement.Above + referenceelement.Prefix + referenceelement.Suffix + referenceelement.ValueOverride t = Transaction(doc, 'Dimension "Class B Lap Splice"')