def get_mark_selected_or_none(): if ui.Selection(): element = ui.Selection()[0] start_number = int(element.parameters.builtins['DOOR_NUMBER'].value) logger.debug('Get start number [{}]'.format(start_number)) return start_number
def get_dwgs(): selection_elems = ui.Selection() for elem in selection_elems: if type(elem.unwrap()) is DB.ImportInstance: logger.debug('Get selected dwg: {}'.format( elem.get_category().name)) yield elem
def main(): selection = ui.Selection() adder_number = get_adder_number_from_user(count=len(selection)) for element in selection: add_number(element, adder_number) logger.debug('End Script')
def Editors(): els = ui.Selection() if AlertSelection(els): if revit.doc.IsWorkshared: ExportToExcel(els) else: Alert("Can't get information from a non Workshared document.", title="neoCL | Edited By", header="Warning")
def RemoveAnnotationFromSelection(): els = ui.Selection() catTypes = [x for x in GetAllCatTypes() if (x not in ['Annotation'])] els = FilterCategoryType(els, catTypes) msg = "Any elements non Annotantion in selection." if AlertSelection(els, msg): try: eids = List[ElementId](GetListOfIds(els)) uidoc.Selection.SetElementIds(eids) except: Alert("Can't create new selection!", title="neoCL | Selection", header="Error trying to select...")
def sheet_selection(): sheet_list = [] elements = ui.Selection() for el in elements: if isinstance(el, db.ViewSheet): sheet_list.append(el) else: message = '{}を除外します'.format(el.Name) ui.forms.Alert(content=message, title="シート以外が選択されました", exit=False) if not sheet_list: ui.forms.Alert(content='シートを選択してください', title="選択エラー", exit=True) return sheet_list
def get_selected_sheet_ids(): """ Получить список id выбранных в ревите листов :return: Список id выбранных видов :rtype: List[DB.ElementId] """ sheets = [] for elem in ui.Selection(): if elem.Category.Id == DB.Category.GetCategory( doc, DB.BuiltInCategory.OST_Sheets).Id: sheets.append(elem.Id) if not sheets: raise SheetsNotSelected( 'No sheet is selected. Please select one or several views') return sheets
def SelectSimilar(where='ActiveView'): els = ui.Selection() elTypes = FilterSelection(els) colEls = [] colElsc = [] for pmEnum, pmValues in elTypes.items(): for elt in pmValues: param_id = DB.ElementId(pmEnum) parameter_filter = db.ParameterFilter(param_id, equals=elt) if where == 'ActiveView': colEls = db.Collector(view=doc.ActiveView, parameter_filter=parameter_filter) elif where == 'Project': colEls = db.Collector(parameter_filter=parameter_filter) else: return False colEls = colEls.get_elements(True) colElsc += colEls SetFocus(colElsc)
TextBox('textbox1', Text="AR - CODIGO"), Label('Description parameter:'), TextBox('textbox2', Text="AR - DESCRICAO"), Button('Search base', on_click=ButtonClass.Importarbase), Separator(), Button('Process') ] form = FlexForm('Insert code in selected pipes', components) form.show() #Tubos = db.Collector(of_category='OST_PipeCurves',is_not_type=True) #ConexoesTubo = db.Collector(of_category='OST_PipeFitting',is_not_type=True) #AcessoriosTubo = db.Collector(of_category='OST_PipeAccessory',is_not_type=True) #Equipamentos = db.Collector(of_category='OST_PlumbingFixtures',is_not_type=True) Tubos = ui.Selection() Elementos = Tubos """ if len(Tubos)>0: for i in range(0,len(Tubos)): Elementos.append(Tubos[i]) if len(ConexoesTubo)>0: for i in range(0,len(ConexoesTubo)): Elementos.append(ConexoesTubo[i]) if len(AcessoriosTubo)>0: for i in range(0,len(AcessoriosTubo)): Elementos.append(AcessoriosTubo[i]) """ with open(file, 'r') as csv_file: lines = csv_file.readlines()
__doc__ = 'Makes Floor objects from selected rooms.' __author__ = '@gtalarico' __title__ = "Make\nFloors" # __window__.Close() import sys import os from collections import namedtuple from Autodesk.Revit.DB.Architecture import Room import rpw from rpw import doc, uidoc, DB, UI, db, ui selection = ui.Selection() selected_rooms = [e for e in selection.elements if isinstance(e, Room)] if not selected_rooms: UI.TaskDialog.Show('MakeFloors', 'You need to select at lest one Room.') sys.exit() floor_types = rpw.db.Collector(of_category='OST_Floors', is_type=True).elements floor_type_options = {DB.Element.Name.GetValue(t): t for t in floor_types} floor_type = ui.forms.SelectFromList('Make Floors', floor_type_options, description='Select Floor Type') floor_type_id = floor_type.Id
"Ceilings": ceil_cat, "Generic Models": gen_cat } components = [ Label('Выберите категорию элементов для присоединения:'), ComboBox('categories', cats), Button('Select') ] form = FlexForm('Choose element category ', components) form.show() if form == False: sys.exit() else: selected_cat = form.values['categories'] obj_type = ObjectType.Element selection = ui.Selection().PickObjects(obj_type, "Choose elements to join") results = [] with db.Transaction('Multiple join'): for A in selected_cat: #print(A) for B in selection: #print(doc.GetElement(B.ElementId)) try: result = Autodesk.Revit.DB.JoinGeometryUtils.JoinGeometry( doc, A, doc.GetElement(B.ElementId)) results.append(result) except: pass
from collections import namedtuple #import revitpythonwrapper by guitalarico import rpw from rpw import doc, uidoc, DB, UI, db, ui from rpw.ui.forms import (FlexForm, Label, ComboBox, TextBox, TextBox, Separator, Button, CheckBox) import sys def units(mmToFeets): dut = DisplayUnitType.DUT_MILLIMETERS return UnitUtils.ConvertToInternalUnits(mmToFeets, dut) # wall selection walls = ui.Selection().get_elements(wrapped=False) if not walls: UI.TaskDialog.Show( 'Развёртка стен', 'Для создания развёртки необходимо выделяить как минимум одну стену.') sys.exit() #Get sec_types sec_types = [] #sec_types = rpw.db.Collector(of_category='OST_Walls', is_type=True).get_elements(wrapped=False) view_types = FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements() for types in view_types: #if types.ViewFamily.ToString() == "Section" or types.ViewFamily.ToString() == "Detail": if types.ViewFamily.ToString() == "Section": sec_types.append(types)
doc = __revit__.ActiveUIDocument.Document # noqa app = doc.Application docCreation = doc.Create appCreation = app.Create area_collector = db.Collector(view=doc.ActiveView, of_category='OST_AreaSchemeLines', is_type=False) area_elements = area_collector.get_elements() print area_collector print area_elements selection = ui.Selection(area_elements) t = Transaction(doc, 'room bounds') t.Start() curve_array = CurveArray() for curve in area_elements: sketchplane = curve.SketchPlane curves = curve_array.Append(curve.GeometryCurve) print curve_array print curve_array print sketchplane docCreation.NewRoomBoundaryLines(sketchplane, curve_array, view=doc.ActiveView)
SelectMirroredDoors Selects All Door Instances that have been Mirrored. TESTED REVIT API: 2015 | 2016 Copyright (c) 2014-2016 Gui Talarico github.com/gtalarico This script is part of PyRevitPlus: Extensions for PyRevit github.com/gtalarico -------------------------------------------------------- PyRevit Notice: Copyright (c) 2014-2016 Ehsan Iran-Nejad pyRevit: repository at https://github.com/eirannejad/pyRevit """ __doc__ = "Выделить все отзеркаленные двери на выбранном виде / Selects All Door Instances that have been Mirrored." __author__ = '@gtalarico' __title__ = "Select Mirrored\nDoors" from rpw import doc, uidoc, DB, UI, db, ui doors = db.Collector(of_category='Doors').get_elements(wrapped=True) mirrored_door = [door for door in doors if getattr(door, 'Mirrored', False)] msg = "Mirrored: {} of {} Doors".format(len(mirrored_door), len(doors)) ui.forms.Alert(msg, title="Mirrored Doors") selection = ui.Selection(mirrored_door)
for el_id in element_ids: el = doc.GetElement(el_id) if isinstance(el, DB.ViewSheet): sheet_list.append(el) else: message = '{}を除外します'.format(el.Name) ui.forms.Alert(content=message, title="シート以外が選択されました", exit=False) if not sheet_list: ui.forms.Alert(content='シートを選択してください', title="選択エラー", exit=True) else: print(sheet_list) """ # RPW WrappedElement elements = ui.Selection() sheet_list = [] for el in elements: if isinstance(el, db.ViewSheet): sheet_list.append(el) else: message = '{}を除外します'.format(el.Name) ui.forms.Alert(content=message, title="シート以外が選択されました", exit=False) if not sheet_list: ui.forms.Alert(content='シートを選択してください', title="選択エラー", exit=True) else: print(sheet_list) # RPW UnwrappedElement
NoUnits = [] MissingUnits = [] print("\n") for furn in furn_elements: furn_symb = furn.get_symbol() furn_getfam = furn.get_family() furn_name = furn_getfam.name if ('GRP' in furn_name): MissingUnits.append(furn_getfam) for furn in furn_elements: furn_symb = furn.get_symbol() furn_getfam = furn.get_family() param = int(furn_symb.parameters['Hana-SeatingCapacity'].value) if (param > 0): Units.append(furn) else: NoUnits.append(furn) #rather than put furn in there, put furn_getfam #select only works with FamilyInstance..doesn't work with Symbols or Family not sure why print("\n") print 'THESE FAMILIES HAVE HANA-SEATING CAPACITY', Units, ("\n") print 'THESE FAMILIES DO NOT', NoUnits, ("\n") print 'THESE FAMILIES HAVE GRP IN NAME', MissingUnits selection = ui.Selection(Units)
def ExportXL(presetParams): global XL, wb, sh global rID, rFa, rTy global ar, rt, ct, re, ce XL, wb = GetWb() try: sh = wb.Worksheets(shName) except: pass sh.Activate XL.DisplayAlerts = False rID = sh.Range[rg(rt, ct)] rFa = sh.Range[rg(rt, ct + 1)] rTy = sh.Range[rg(rt, ct + 2)] GetDicOfColumns(sh) SetFormatsBefore(presetParams) rID.Value2 = "neoCL.iParametersEditor | Loading..." XL.ScreenUpdating = True XL.ScreenUpdating = False XL.Calculation = False rFa.Value2 = "Family" rTy.Value2 = "Type" sel = ui.Selection() print('[neoCL.iParametersEditor]') if len(sel) < 1: sel = UserSelect() if len(sel) < 1: print('No elements selected!\nProcess ended.') return False print('\n' + str(len(sel)) + ' element(s) selected.\nExporting to Excel... please wait.') print('\nSelected Elements : loading...') ctEq = 1 for eq in sel: print(str(ctEq) + ') ' + eq.name + " | ID[" + str(eq.Id) + "]") ctEq += 1 if presetParams: # Export only parameters defined in Excel dic = GetDicOfColumns(sh) for eq in sel: sh.Range[rg(ar, ce)].Value2 = "'" + str(eq.Id) for col in dic: try: pm = eq.parameters[dic[col]] AddParam(pm, col) except: pass ar += 1 else: # Export all allowed parameters of elements for eq in sel: pmap = eq.parameters.all pmap.sort(key=lambda x: x.name, reverse=False) pmap.sort(key=lambda x: x.Definition.ParameterGroup, reverse=False) sh.Range[rg(ar, ce)].Value2 = "'" + str(eq.Id) for pm in pmap: if IsValidParam(pm): AddParam(pm, None) ar += 1 rID.Value2 = "ID" SetFormatsAfter() XL.ScreenUpdating = True XL.Calculation = True XL.DisplayAlerts = True #ap.BringExcelToFront(XL) print("\nExcel is ready!")
SelectMirroredWindows Selects All Window Instances that have been Mirrored. TESTED REVIT API: 2015 | 2016 Copyright (c) 2014-2016 Gui Talarico github.com/gtalarico This script is part of PyRevitPlus: Extensions for PyRevit github.com/gtalarico -------------------------------------------------------- PyRevit Notice: Copyright (c) 2014-2016 Ehsan Iran-Nejad pyRevit: repository at https://github.com/eirannejad/pyRevit """ #pylint: disable=E0401,W0621,W0631,C0413,C0111,C0103 __doc__ = "Selects All Window Instances that have been Mirrored." __author__ = '@gtalarico' __title__ = "Select Mirrored\nWindows" from rpw import db, ui windows = db.Collector(of_category='Windows').get_elements(wrapped=True) mirrored_windows = [x for x in windows if getattr(x, 'Mirrored', False)] msg = "Mirrored: {} of {} Windows".format(len(mirrored_windows), len(windows)) ui.forms.Alert(msg, title="Mirrored Windows") selection = ui.Selection(mirrored_windows)
TextBox('textbox1', Text="AR - CODIGO"), Label('Description parameter:'), TextBox('textbox2', Text="AR - DESCRICAO"), Button('Search base', on_click=ButtonClass.Importarbase), Separator(), Button('Process') ] form = FlexForm('Insert code in selected pipe connections', components) form.show() #Tubos = db.Collector(of_category='OST_PipeCurves',is_not_type=True) #ConexoesTubo = db.Collector(of_category='OST_PipeFitting',is_not_type=True) #AcessoriosTubo = db.Collector(of_category='OST_PipeAccessory',is_not_type=True) #Equipamentos = db.Collector(of_category='OST_PlumbingFixtures',is_not_type=True) Elementos = ui.Selection() """ if len(Tubos)>0: for i in range(0,len(Tubos)): Elementos.append(Tubos[i]) if len(ConexoesTubo)>0: for i in range(0,len(ConexoesTubo)): Elementos.append(ConexoesTubo[i]) if len(AcessoriosTubo)>0: for i in range(0,len(AcessoriosTubo)): Elementos.append(AcessoriosTubo[i]) if len(AcessoriosTubo)>0: for i in range(0,len(Equipamentos)): Elementos.append(Equipamentos[i])