def get_from_win_form(): """ Получить от пользователя значение шаблона и на что заменить :return: две строки :rtype: tuple[str, str] """ components = [ Label('Введите шаблон:'), TextBox('Template', Text="A"), Label('Заменить на:'), TextBox('New_text', Text="Q"), Separator(), Button('Find and Replace') ] form = FlexForm('Title', components) form.show() if 'Template' in form.values and 'New_text' in form.values: template = form.values['Template'] new_text = form.values['New_text'] logger.info('Get from user template {} and new text {}'.format( repr(template), repr(new_text))) return template, new_text raise ElemNotFound('User canceled form')
def form(): floor_types = rpw.db.Collector(of_category='OST_Floors', is_type=True).get_elements() wall_types = rpw.db.Collector(of_category='Walls', is_type=True, where=lambda x: x.GetParameters('Width')).get_elements() components = [ Label('Finish floor type:'), ComboBox('floor_type_id', {ft.parameters['Type Name'].AsString(): ft.Id for ft in floor_types}), # Label('No Floors'), CheckBox('make_floors', 'make Floors'), Label('Finish wall type:'), ComboBox('wall_type_id', {wt.parameters['Type Name'].AsString(): wt.Id for wt in wall_types}), Label('Finish wall height (mm):'), TextBox('wall_height', default='3000'), Button('Create Finish Walls') ] ff = FlexForm('Create Finish Walls', components) ff.show() if ff.values['wall_type_id'] and ff.values['wall_height']: try: floor_type = rpw.db.Element.from_id(ff.values['floor_type_id']) wall_type = rpw.db.Element.from_id(ff.values['wall_type_id']) wall_height = float(ff.values['wall_height']) make_floors = ff.values['make_floors'] return wall_type, wall_height, floor_type, make_floors except: return
def SetFormComponents(self): from rpw.ui.forms import Button, CheckBox, Label, Separator, TextBox # why does this have to be inside method? self.components = [CheckBox("checkbox1", "VIEWS", default=False), CheckBox("checkbox2", "SHEETS", default=False), CheckBox("checkbox3", "ROOMS", default=False), Label("SEARCH TEXT"), TextBox("textbox1"), Label("TARGET TEXT"), TextBox("textbox2"), Separator(), Button('Go') ]
def flex_form(combo_values = dict, default_text = str): """Main Window""" components = [Label('Select View Template:'), ComboBox('template', combo_values), Separator(), Label('Enter Suffix:'), TextBox('suffix', Text= default_text), Separator(), CheckBox('select_levels', 'Select Levels'), CheckBox('all_levels', 'All Levels',default= True), Button('Create Views') ] form = FlexForm('Create Views', components) form.show() return form
def form(): wall_types = rpw.db.Collector(of_category='Walls', is_type=True, where=lambda x: x.GetParameters('Width')).get_elements() components = [Label('Finish wall type:'), ComboBox('wall_type_id', {wt.parameters['Type Name'].AsString(): wt.Id for wt in wall_types}), Label('Finish wall height (mm):'), TextBox('wall_height'), Button('Create Finish Walls')] ff = FlexForm('Create Finish Walls', components) ff.show() if ff.values['wall_type_id'] and ff.values['wall_height']: try: wall_type = rpw.db.Element.from_id(ff.values['wall_type_id']) wall_height = float(ff.values['wall_height']) return wall_type, wall_height except: return
def config_method(): prev_choice = get_config() opts = ["Extrusion", "Freeform"] components = [ Label("Choose method:"), ComboBox(name="method", options=opts, default=prev_choice), Button("Remember choice") ] form = FlexForm("Settings", components) ok = form.show() if ok: res = form.values["method"] if res: save_config(res) return res else: sys.exit()
def main(): try: elements = selection.select_objects_by_category('Windows', 'Doors') except: return all_beam_types = rpw.db.Collector(of_category='Structural Framing', is_type=True).get_elements(wrapped=False) components = [ Label('Lintel (Beam) Type:'), ComboBox('beam_type', { b.LookupParameter('Type Name').AsString(): b for b in all_beam_types }), Label('L1:'), TextBox('l1'), Label('L2:'), TextBox('l2'), Button('Create Lintels') ] ff = FlexForm('Create Lintels', components) ff.show() if ff.values: beam_type = ff.values['beam_type'] try: l1 = float(ff.values['l1']) l2 = float(ff.values['l2']) except: return if not beam_type.IsActive: with rpw.db.Transaction('Activate Beam Type'): beam_type.Activate() for e in elements: create_lintel(e, l1, l2, beam_type)
def SetFormComponents(self): from rpw.ui.forms import Button, CheckBox, ComboBox, Label, Separator, TextBox # why does this have to be inside method? # set form buttons, text boxes, etc... | TextBox(componentName, defaultValue) is an option for manual entry # dropdown transomHeightOptions from above is not currently being used self.components = [ #Label('CHOOSE FLOORS'), #CheckBox("checkbox1", "something", default=True), Separator(), Label('PICK SYSTEM'), ComboBox("combobox1", self.GUI_SF_systemOptions, default=self.defaultSystem), Label('HEAD HEIGHT'), ComboBox("combobox2", self.GUI_SF_heightOptions, default=self.defaultHeight), Label('DIVISION TYPE'), ComboBox("combobox4", self.GUI_SF_divisionOptions, default=self.defaultDivOption), Label('DIVISION WIDTH'), ComboBox("combobox5", self.GUI_SF_panelWidthOptions, default=self.defaultWidthOption), Separator(), CheckBox("checkbox1", "NIB WALL SPLIT", default=True), CheckBox("checkbox2", "NIB WALL SPLIT ONLY", default=False), ComboBox("combobox6", self.GUI_nibWallOptions, default=self.defaultNibWallOption), ComboBox("combobox7", self.GUI_nibWallLengthOptions, default=self.defaultNibWallLengthOption), Separator(), Button('Go') ]
default="SSG_TB_8.5x11_PDF: Empty"), Label("View Template"), ComboBox("combobox4", list_to_dict(view_templates), default="SSG_Elevation - Legend"), Label("Separator Line Style"), ComboBox( "combobox6", list_to_dict(all_text), default='SSG_3/32" - Segoe UI Semibold - Dark Blue', ), Label("Sheet Header"), ComboBox("combobox5", list_to_dict(gsCat), default="06"), Label("Header Text Style"), TextBox("textbox1", Text="Legend"), Button("Continue"), ] form = FlexForm("Legend PDF", components) if form.show(): border_size = form.values["combobox1"] tag = form.values["combobox2"] pdf_tb = form.values["combobox3"] view_temp = form.values["combobox4"] text = form.values["combobox6"] line_style = form.values["combobox5"] short_descript = form.values["textbox1"] plan_view = revit.doc.ActiveView forms.check_viewtype(plan_view, DB.ViewType.FloorPlan, exitscript=True)
elements = rpw.db.Collector(of_class='FamilyInstance', view=doc.ActiveView).wrapped_elements except: sys.exit() else: elements = selection.wrapped_elements editable = {p.name: p.name for p in elements[0].parameters.all if not p.IsReadOnly and p.StorageType==rpw.DB.StorageType.String} components = [ComboBox('parameter', editable), Label('Replace:'), TextBox('old'), Label('With:'), TextBox('new'), Button('Replace'), ] ff = FlexForm('Replace Parameter values', components) ff.show() if ff.values: for element in elements: try: p = element.parameters[ff.values['parameter']] if ff.values['old'] in p.value: new_name = p.value.replace(ff.values['old'], ff.values['new']) with rpw.db.Transaction('Rename {} to {}'.format(p.value, new_name)): p.value = new_name except Exception, e: print(e)
for level in level_elements: level_id = level.Id keys = level.Name values = level_id levels_dict[keys] = levels_dict.get(keys, values) # Create a list of all Levels levels_list = [] for level in level_elements: level_id = levels_list.append(level.Id) # FlexForm components = [Label('Test:'), ComboBox('test', levels_dict), Button('Select')] form = ui.forms.FlexForm('Set Level', components) form_show = form.show() # returns a dictionary with one object form_value = form.values # returns a list with one object form_value1 = form_value.values() # Start transaction t = db.Transaction() t.Start() for wall in wall_elements:
ComboBox( 'cut_element', { 'floor': 'floor', 'column': 'column', 'beam': 'beam', 'wall': 'wall', 'Generic Model': 'generic_model', }), Separator(), Label('Elements to join:'), CheckBox('join_floor', 'floor'), CheckBox('join_column', 'column'), CheckBox('join_beam', 'beam'), CheckBox('join_wall', 'wall'), CheckBox('join_generic_model', 'Generic Model'), Button('Join') ] if rpw.ui.Selection(): selected = True else: selected = False ff = FlexForm("Join cấu kiện", components) ff.show() if ff.values: cut_element = ff.values['cut_element'] for k, v in ff.values.items(): if k.startswith('join_') and v == True:
Separator, Button, CheckBox) from rpw import ui from rpw.ui.forms import select_file from Autodesk.Revit.DB import Transaction from Autodesk.Revit.DB.Plumbing.PlumbingUtils import BreakCurve from rpw.db.xyz import XYZ import csv try: components = [ Label('Codes in selected pipes:'), Label('Code parameter:'), 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:
'Sheet Size Parameter Name', 'Default Sheet Size', 'Sheet Orientation Parameter Name' ]) components = addComboBox(components, config, 'Default Sheet Orientation', ['Landscape', 'Portrait']) components = addFields( components, ['---', 'PDF Printer Address', 'PDF Temporary Output Path', '---']) components = addComboBox( components, config, 'DWG Export Setup', list( revitron.DB.BaseExportOptions.GetPredefinedSetupNames( revitron.DOC))) components = addComboBox( components, config, 'DWG Export Unit', ['Meter', 'Centimeter', 'Millimeter', 'Foot', 'Inch']) components.append(Label('')) components.append(Button('Open Documentation', on_click=openHelp)) components.append(Button('Save')) form = FlexForm('PDF and DWG Export Settings', components) form.show() if form.values: revitron.DocumentConfigStorage().set('revitron.export', form.values)
'and the repository URL separated by a TAB as follows:', FontSize=14, Height=140, Width=650), Label( 'ui https://ui-extension-repository.git\r\nlib https://lib-extension-repository.git', FontFamily=System.Windows.Media.FontFamily('Consolas'), FontSize=14, Height=50, Width=650), TextBox('extensions', Text=config, TextWrapping=System.Windows.TextWrapping.Wrap, AcceptsTab=True, AcceptsReturn=True, Multiline=True, Height=200, Width=650, FontFamily=System.Windows.Media.FontFamily('Consolas'), FontSize=14), Button('Open Documentation', on_click=openHelp, Width=650), Button('Save', Width=650) ] form = FlexForm('Project Extensions', components) form.show() if 'extensions' in form.values: revitron.DocumentConfigStorage().set('rpm.extensions', form.values.get('extensions'))
def main(): components = [Label('Thickness (mm)'), TextBox('thickness'), Button('Create Finish Layer') ] ff = FlexForm('Create Finish Layer', components) ff.show() try: thickness = int(ff.values['thickness']) if not thickness: return except: return try: elements = selection.select_objects_by_category('Structural Framing', 'Structural Columns', 'Floors', 'Generic Models', 'Walls', 'Stairs') except: return for element in elements: host_faces = get_faces(element) host_solids = get_solids(element) cross_elements = get_crossing_elements(element, thickness/304.8) cross_solids = [] for cross_element in cross_elements: cross_solids.extend(get_solids(cross_element)) if len(host_solids) > 1: cross_solids.extend(host_solids) host_name = element.LookupParameter('UDIC_Name').AsString() host_category = element.Category.Name if host_category == 'Structural Columns' or host_category == 'Stairs': param = 'Base Level' elif host_category == 'Structural Framing': param = 'Reference Level' elif host_category == 'Floors': param = 'Level' elif host_category == 'Walls': param = 'Base Constraint' elif host_category == 'Generic Models': param = 'Level' formwork_level = element.LookupParameter(param).AsValueString() with rpw.db.Transaction('Create Finish Layer for {}'.format(element.Id)): for face in host_faces: try: formwork, angle_text = create_formwork(face, thickness, cross_solids) except Exception as e: continue area = formwork.Volume/(thickness/304.8) if area == 0: continue ds = DirectShape.CreateElement(doc, ElementId(BuiltInCategory.OST_GenericModel)) ds.SetShape([formwork]) ds.LookupParameter('UDIC_Name').Set('Finish Layer {}'.format(element.Id)) ds.LookupParameter('UDIC_Formwork_Type').Set(angle_text) if host_name: ds.LookupParameter('UDIC_Formwork_Hostname').Set(host_name) ds.LookupParameter('UDIC_Formwork_Hostcategory').Set(host_category) ds.LookupParameter('UDIC_Formwork_Level').Set(formwork_level) ds.LookupParameter('UDIC_Formwork_Area').Set(area)
def storefront_set_config(self): """ Set configurations and load families. """ # Create Menu from rpw.ui.forms import Label, ComboBox, Separator, Button, FlexForm systemOptions = self.availableSystems heightOptions = self.heightOptions divisionTypeOptions = self.divisionOptions widthOptions = self.panelWidthOptions #Make sure default values are set if not self.currentConfig["selectedSystem"] in systemOptions.values(): defaultSystem = systemOptions.keys()[0] else: defaultSystem = systemOptions.keys()[systemOptions.values().index(self.currentConfig["selectedSystem"])] if not self.currentConfig["headHeight"] in heightOptions.values(): defaultHeight = heightOptions.keys()[0] else: defaultHeight = heightOptions.keys()[heightOptions.values().index(self.currentConfig["headHeight"])] if not self.currentConfig["spacingType"] in divisionTypeOptions.values(): defaultDivOption = divisionTypeOptions.keys()[0] else: defaultDivOption = divisionTypeOptions.keys()[divisionTypeOptions.values().index(self.currentConfig["spacingType"])] if not self.currentConfig["storefrontPaneWidth"] in widthOptions.values(): defaultWidthOption = widthOptions.keys()[0] else: defaultWidthOption = widthOptions.keys()[widthOptions.values().index(self.currentConfig["storefrontPaneWidth"])] components = [Label('PICK SYSTEM'), ComboBox("combobox1", systemOptions, default=defaultSystem), Label('HEAD HEIGHT'), ComboBox("combobox2", heightOptions, default=defaultHeight), Label('DIVISION TYPE'), ComboBox("combobox3", divisionTypeOptions, default=defaultDivOption), Label('DIVISION WIDTH'), ComboBox("combobox4", widthOptions, default=defaultWidthOption), Separator(), Button('Go')] form = FlexForm("Storefront Tools V3", components) form.show() if not form.values: raise Exception("ABORTED!") else: selectedSystem = form.values["combobox1"] headHeight = float(form.values["combobox2"]) partialHeadHeight = float(form.values["combobox2"]) spacingType = form.values["combobox3"] storefrontPaneWidth = float(form.values["combobox4"]) # Load familes loadedFamilies = self.storefront_load_families(True) # Save when the config was set. projectInfo = doc.ProjectInformation projectId = projectInfo.Id projectName = None for p in projectInfo.Parameters: if p.Definition.Name == "Project Name": projectName = p.AsString() todaysDate = str(dt.Today.Month)+"-"+str(dt.Today.Day)+"-"+str(dt.Today.Year) userConfigs = {"projectName": projectName, "projectId": projectId.IntegerValue, "configDate": todaysDate, "headHeight": headHeight, "storefrontPaneWidth" : storefrontPaneWidth, "spacingType" : spacingType, "families": loadedFamilies, "selectedSystem": selectedSystem} self.storefront_save_config(selectedSystem, userConfigs)
Label('Select Rectangular Pile:'), ComboBox('pile_id', {f.Name: f.Id for f in foundations}), Label('Pile width (D):'), TextBox('pile_width'), Label('Number of piles along Length:'), TextBox('piles_along_length'), Label('Number of piles along Width:'), TextBox('piles_along_width'), Label('Pile spacing along Length:'), TextBox('pile_spacing_along_length'), Label('Pile spacing along Width:'), TextBox('pile_spacing_along_width'), Label('Length cover:'), TextBox('length_cover'), Label('Width cover:'), TextBox('width_cover'), Label('Foundation Thickness:'), TextBox('thickness'), Label('Pile Cut-off:'), TextBox('pile_cutoff'), Label('New Foundation Family Name:'), TextBox('new_foundation_family_name'), Separator(), Button('Create foundation')] ff = FlexForm("Modify Structural Foundation Family", components) ff.show() if ff.values: main()
UI.TaskDialog.Show('MakeWalls', 'You need to select at lest one Room.') sys.exit() #Get wall_types wall_types = rpw.db.Collector(of_category='OST_Walls', is_type=True).get_elements(wrapped=False) #Select wall type wall_type_options = {DB.Element.Name.GetValue(t): t for t in wall_types} #Select wall types UI components = [ Label('Выберите тип отделки стен:'), ComboBox('wl_type', wall_type_options), Label('Введите высоту стены:'), TextBox('h_offset', wall_custom_height="50.0"), CheckBox('checkbox1', 'Брать высоту стены из помещений'), Button('Select') ] form = FlexForm('Создать отделку стен', components) win = form.show() #Get the ID of wall type if win == True: wall_type = form.values['wl_type'] wall_type_id = wall_type.Id else: sys.exit() # Duplicating wall type creating the same layer set with double width # to deal with the offset API issue def duplicate_wall_type(type_of_wall):
from rpw import revit, db from rpw.ui.forms import (FlexForm, Label, ComboBox, TextBox, TextBox, Separator, Button, CheckBox) from rpw.ui.forms import select_file from Autodesk.Revit.DB import Transaction from Autodesk.Revit.DB.Plumbing.PlumbingUtils import BreakCurve from rpw.db.xyz import XYZ import csv try: components = [ Label('Clear Mark Parameter:'), Label('Mark Parameter:'), TextBox('textbox1', Text="Mark"), Separator(), Button('Process') ] form = FlexForm('Clear Mark Parameter', 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) ConexoesDuto = db.Collector(of_category='OST_DuctFitting', is_not_type=True) AcessoriosDuto = db.Collector(of_category='OST_DuctAccessory', is_not_type=True)
def SF_GetUserConfigs(self): """ Set configurations and load families. THIS IS ALSO IDENTICAL TO STOREFRONT GUI, SO IT WILL BE REPLACED BY THAT... """ from rpw.ui.forms import Label, ComboBox, Separator, Button, FlexForm, CheckBox, TextBox # set default storefront system if not self.currentConfig["selectedSystem"] in self.GUI_SFSystemOptions.values(): defaultSystem = self.GUI_SFSystemOptions .keys()[0] else: defaultSystem = self.GUI_SFSystemOptions .keys()[self.GUI_SFSystemOptions.values().index(self.currentConfig["selectedSystem"])] # set default storefront height if not self.currentConfig["headHeight"] in self.GUI_heightOptions.values(): defaultHeight = self.GUI_heightOptions.keys()[0] else: defaultHeight = self.GUI_heightOptions.keys()[self.GUI_heightOptions.values().index(self.currentConfig["headHeight"])] # set default storefront transum height #if not self.currentConfig["transomHeight"] in self.transomHeightOptions.values(): #defaultTransomHeight = self.transomHeightOptions.keys()[0] #else: #defaultTransomHeight = self.transumHeightOptions.keys()[self.transumHeightOptions.values().index(self.currentConfig["transomHeight"])] # set defualt storefront panel division method if not self.currentConfig["spacingType"] in self.GUI_divisionOptions.values(): defaultDivOption = self.GUI_divisionOptions.keys()[0] else: defaultDivOption = self.GUI_divisionOptions.keys()[self.GUI_divisionOptions.values().index(self.currentConfig["spacingType"])] # set default storefront panel width if not self.currentConfig["storefrontPaneWidth"] in self.GUI_panelWidthOptions.values(): defaultWidthOption = self.GUI_panelWidthOptions.keys()[0] else: defaultWidthOption = self.GUI_panelWidthOptions.keys()[self.GUI_panelWidthOptions.values().index(self.currentConfig["storefrontPaneWidth"])] # set default nib wall type if not self.currentConfig["nibWallType"] in self.GUI_nibWallOptions.values(): defaultSplitWallOption = self.GUI_nibWallOptions.keys()[0] else: defaultSplitWallOption = self.GUI_nibWallOptions.keys()[self.GUI_nibWallOptions.values().index(self.currentConfig["nibWallType"])] # set default nib wall length if not self.currentConfig["splitOffset"] in self.GUI_nibWallLengthOptions.values(): defaultNibWallTypeOption = self.GUI_nibWallLengthOptions.keys()[0] else: defaultNibWallTypeOption = self.GUI_nibWallLengthOptions.keys()[self.GUI_nibWallLengthOptions.values().index(self.currentConfig["splitOffset"])] # set form buttons, text boxes, etc... | TextBox(componentName, defaultValue) is an option for manual entry # dropdown transomHeightOptions from above is not currently being used components = [Label('PICK SYSTEM'), ComboBox("combobox1", self.GUI_SFSystemOptions , default=defaultSystem), Label('HEAD HEIGHT'), ComboBox("combobox2", self.GUI_heightOptions, default=defaultHeight), #CheckBox("checkbox1", "Transom (decimal input)", default=False), #TextBox("textbox1", default="12.00 inches"), Label('DIVISION TYPE'), ComboBox("combobox4", self.GUI_divisionOptions, default=defaultDivOption), Label('DIVISION WIDTH'), ComboBox("combobox5", self.GUI_panelWidthOptions, default=defaultWidthOption), Separator(), CheckBox("checkbox2", "Nib Wall Split", default=True), ComboBox("combobox6", self.GUI_nibWallOptions, default=defaultSplitWallOption), ComboBox("combobox7", self.GUI_nibWallLengthOptions, default=defaultNibWallTypeOption), Separator(), Button('Go') ] # Create Menu form = FlexForm("STOREFRONT 2", components) form.show() if not form.values: # better than sys.exit() pyrevit.script.exit() else: selectedSystem = form.values["combobox1"] headHeight = float(form.values["combobox2"]) partialHeadHeight = float(form.values["combobox2"]) #createTransom = form.values["checkbox1"] # filter out inputs with a text character - expand to other types of units #try: #transomHeight = float(form.values["textbox1"]) #except: #transomHeight = float(form.values["textbox1"].split(" inches")[0]) spacingType = form.values["combobox4"] storefrontPaneWidth = float(form.values["combobox5"]) createNibWall = form.values["checkbox2"] nibWallType = form.values["combobox6"] if form.values["combobox7"] == "OPTIMIZED": GUI_nibWallLengthOptions = form.values["combobox7"] else: GUI_nibWallLengthOptions = float(form.values["combobox7"]) # IS THIS DOUBLE LOADING? # Load familes - its not a load, load but I will clarify this later loadedFamilies = self.familyObj.SFLoadFamilies(True) # Save when the config was set. projectInfo = self.doc.ProjectInformation projectId = projectInfo.Id projectName = None for p in projectInfo.Parameters: if p.Definition.Name == "Project Name": projectName = p.AsString() todaysDate = "{0}-{1}-{2}".format(dt.Today.Month, dt.Today.Day, dt.Today.Year) # can also be used as class outputs directly in code self.userConfigs = {"projectName": projectName, "projectId": projectId.IntegerValue, "configDate": todaysDate, "families": loadedFamilies, "selectedSystem": selectedSystem, "headHeight": headHeight, "partialHeadHeight": partialHeadHeight, #"createTransom": createTransom, #"transomHeight": transomHeight, "spacingType": spacingType, "storefrontPaneWidth": storefrontPaneWidth, "createNibWall": createNibWall, "nibWallType": nibWallType, "nibWallLength": GUI_nibWallLengthOptions } # IS THIS SAVING WHAT WILL GET LOADED NEXT TIME? self.familyObj.Run_SaveSFConfigurations(selectedSystem, self.userConfigs)
# -*- coding: utf-8 -*- __title__ = 'Select Elements\nBy UDIC Name' __author__ = 'htl' import clr clr.AddReference('RevitAPI') import Autodesk import rpw from rpw import doc, uidoc from rpw.ui.forms import Label, TextBox, Button, FlexForm from System.Collections.Generic import List workset_table = doc.GetWorksetTable() active_ws_id = workset_table.GetActiveWorksetId() components = [Label('UDIC Name:'), TextBox('name'), Button('Select All')] ff = FlexForm('Select by Name', components) ff.show() if ff.values: s = rpw.db.Collector(is_type=False, view=doc.ActiveView, where=lambda x: x.WorksetId==active_ws_id \ and x.LookupParameter('UDIC_Name') \ and x.LookupParameter('UDIC_Name').AsString()==ff.values['name']) sids = List[rpw.DB.ElementId](s.element_ids) uidoc.Selection.SetElementIds(sids)
for t in Framing_types } Level_type = db.Collector(of_category='Levels', is_type=False).elements Level_type_options = {DB.Element.Name.GetValue(t): t for t in Level_type} components = [ Label('输入图层名称'), TextBox('图层名称', Text="S-STEL-BEAM"), Label('构件名称'), ComboBox('FamilyName', Framing_type_options), Label('标高'), ComboBox('Level', Level_type_options), Label('偏移标高'), TextBox('Offset', Text="-300"), Button('确定') ] form = FlexForm('结构', components) form.show() Value = form.values LayerName = Value['图层名称'] FamilyName = Value['FamilyName'] Level = Value['Level'] Offset = Helper.MmToFeet(float(Value['Offset'])) # def Draw_LinesfromPoints(Points): pass
components_1 = [ Label('SUITE EXTENTS'), Label('Bays Length'), TextBox('textbox1', Text="7000, 8000, 6000, 9000, 5000, 5000, 7000"), Label('Bays Width'), TextBox('textbox2', Text="7000,7000,7000,7000,7000"), Label('Wall Heights'), TextBox('textbox3', Text="7000"), Label('Ceiling Heights'), TextBox('textbox4', Text="7000"), Label('Storefront Distance From Front'), TextBox('textbox5', Text="1000"), CheckBox('checkbox1', 'Rear Left Door'), CheckBox('checkbox2', 'Rear Right Door'), Separator(), Button('Go') ] components_2 = [ Label('FURNITURE & FIXTURES'), Label('Shelving Type:'), ComboBox("combobox1", { "Small": "1200_Width", "Medium": "1800_Width", "Large": "2400_Width" }), Label('Table Type:'), ComboBox("combobox2", { "Small": "1200_Width", "Medium": "1800_Width", "Large": "2400_Width"
ComboBox('combobox2', { 'Doors': 0, 'Rooms': 1 }), Label('Select the name of Excel sheet to import:'), ComboBox('combobox', dicWs), Label( 'Enter the number of rows in Excel you want to integrate to Revit:' ), TextBox('textbox', Text="60"), Label( 'Enter the number of colones in Excel you want to integrate to Revit:' ), TextBox('textbox2', Text="2"), Separator(), Button('OK') ] form = FlexForm('Title', components) form.show() worksheet = form.values['combobox'] rowEnd = convertStr(form.values['textbox']) colEnd = convertStr(form.values['textbox2']) category = form.values['combobox2'] if category == 0: collector = FilteredElementCollector(doc)\ .OfCategory(BuiltInCategory.OST_Doors)\ .WhereElementIsNotElementType()\ .ToElements() else:
from Autodesk.Revit.DB import * from Autodesk.Revit.UI import * import rpw from rpw.ui.forms import Label, CheckBox, Button, TextBox, FlexForm uiapp = __revit__ uidoc = uiapp.ActiveUIDocument app = uiapp.Application doc = uidoc.Document def on_click(sender, e): checkbox = sender grid = checkbox.Parent textbox = grid.Children[2] if checkbox.IsChecked: textbox.IsEnabled = True else: textbox.IsEnabled = False components = [ CheckBox('create_elements', 'Create Formwork Elements', on_click=on_click), Label('Thickness (mm)'), TextBox('thickness', IsEnabled=False), Button('Create Formwork'), ] ff = FlexForm('Create Formwork', components) ff.show()
Label('Search String'), TextBox('search'), Separator(), CheckBox('invert', 'Invert Selection', default=False) ] if selection: components.append( CheckBox('selection', 'Search in selection only', default=True)) else: components.append( CheckBox('viewOnly', 'Search in this view only', default=False)) components.append( Button('Select', Width=100, HorizontalAlignment=System.Windows.HorizontalAlignment.Right)) form = FlexForm('Select by Parameter', components) form.show() if 'search' in form.values: scope = False if 'selection' in form.values and form.values['selection']: scope = selection else: if 'viewOnly' in form.values and form.values['viewOnly']: scope = revitron.ACTIVE_VIEW.Id
for types in view_types: #if types.ViewFamily.ToString() == "Section" or types.ViewFamily.ToString() == "Detail": if types.ViewFamily.ToString() == "Section": sec_types.append(types) #Select section type sec_type_options = {DB.Element.Name.GetValue(t): t for t in sec_types} components = [ Label('Выберите тип разреза:'), ComboBox('s_type', sec_type_options), Label('Введите привязку разреза к стене, мм'), Label('(по умолчанию 50мм):'), TextBox('s_offset', sec_offset="50.0"), CheckBox('flip', 'Развернуть разрез на 180'), Button('Start') ] form = FlexForm('Создать развёртку стены', components) win = form.show() if win == False: sys.exit() # user offset (crop region = far clip) if form.values['s_offset'] != "": offset = units(float(form.values['s_offset'])) else: offset = units(50) viewFamilyTypeId = form.values['s_type'].Id
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), Separator(), Button("Select") ] form = FlexForm("Settings", components) form.show() chosen_wall_type = form.values["combobox1"] chosen_phase = form.values["combobox2"] # collect walls in project that are Basic walls and not in Insulation Phase coll_all_walls = DB.FilteredElementCollector(revit.doc) \ .OfClass(DB.Wall) \ .WhereElementIsNotElementType() \ .ToElements() ins_walls = [ w for w in coll_all_walls if w.WallType.Kind == DB.WallKind.Basic and wall_type_has_ins(w.WallType)
# Get Available Schedules collection = FilteredElementCollector( doc ).OfCategory( BuiltInCategory.OST_Schedules ) schedule_dict = { e.Name:e for e in collection if not e.Definition.IsKeySchedule and e.Definition.CategoryId in [ family.FamilyCategoryId for family in family_dict.values() ] } if len(family_dict) > 0 and len(schedule_dict) > 0: # Create FlexForm components = [ ComboBox('schedule', schedule_dict, sort=True), CheckBox('purge', 'Purge Family Parameters (Recommended)', default=True), Separator(), Button('Schedule') ] form = FlexForm('Select Schedule', components) form.show() # Get FlexForm Values scheduleSelection = form.values.get('schedule') toPurge = form.values.get('purge') # If User Cancels Script if scheduleSelection is None: sys.exit(1) # Get Shared Paramters from Schedule's Fields scheduleDefinition = scheduleSelection.Definition schedulableFields = [ scheduleDefinition.GetField( index ).GetSchedulableField()