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 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 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, 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') ]
pass components = [ Label('Cut 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()
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)
if not selected_rooms: 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
# get the PrintManger from the current document printman = doc.PrintManager # When this is run, a dialog pops up: Freepdf cannot be used with 95x90 print # settings. The "in-session print settings will be used" # - This dialog can not be dissabled. # set this PrintManager to use the "Selected Views/Sheets" option printman.PrintRange = PrintRange.Select # PrintRange is a different class # get the ViewSheetSetting which manages the view/sheet set information of current document viewshsetting = printman.ViewSheetSetting # returns ViewsheetSetting object, # textin Dialog:FlexForm from rpw, components = [Label('Enter Name: '), TextBox('textbox1', Text=""), CheckBox('checkbox1', 'Overwrite, if name exists', default=True), Button('OK')] textin = FlexForm('New ViewSheetSet', components) textin.show() print(textin.values) # with Transaction(doc, 'Created Print Set'): #vsexist = True if textin.values["textbox1"] in allviewss.keys() # else 3 if len(textin.values) == 0 else False try: if textin.values["textbox1"] in allviewss.keys() : vsexist = True 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()
UI.TaskDialog.Show('Создать отделку потолка', 'Необходимо выбрать помещение.') sys.exit() #Get ceiling_types ceiling_types = rpw.db.Collector(of_category='OST_Roofs', is_type=True).get_elements(wrapped=False) #Select ceiling type ceiling_type_options = {DB.Element.Name.GetValue(t): t for t in ceiling_types} #Select ceiling types UI components = [Label('Выберите тип потолка:'), ComboBox('cl_type', ceiling_type_options), Label('Введите привязку потолка к уровню :'), TextBox('h_offset', ceiling_offset="50.0"), CheckBox('checkbox1', 'Из помещения'), Button('Select')] form = FlexForm('Создать отделку потолка',components) win = form.show() if win == False: sys.exit() #Get the ID of ceiling ( NewFootPrintRoof ) ceiling_type_id = form.values['cl_type'].Id if form.values['h_offset'] != "": offset3 = float(form.values['h_offset']) else: offset3 = 2000 f = []
return literal_eval(value) except Exception: # If that doesn't work, assume it's an unquoted string return value with open(source_file, 'rb') as csv_file: for row in DictReader(csv_file, quoting=QUOTE_NONE): yield {k: parse_value(k, v) for k, v in row.iteritems()} # ensure active document is a family document forms.check_familydoc(revit.doc, exitscript=True) components = [ Label('Choose Parameters'), CheckBox('checkbox1', 'Price', default=True), CheckBox('checkbox2', 'Weight'), CheckBox('checkbox3', 'Product Code'), # Separator(), # Label('Dimensions'), # CheckBox('checkbox4', 'Standard Sizes'), # CheckBox('checkbox5', 'Min & Max Sizes'), Button('Select') ] form = FlexForm('CSV to Formulas', components) if form.show(): priceChecked = form.values['checkbox1'] weightChecked = form.values['checkbox2'] codeChecked = form.values['checkbox3']
tt = Transaction(doc, "Retail Automation") #UI form organization 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", {
#Get floor_types floor_types = rpw.db.Collector(of_category='OST_Floors', is_type=True).get_elements(wrapped=False) #Select floor type floor_type_options = {DB.Element.Name.GetValue(t): t for t in floor_types} #Select floor types UI floor_type_id = "" components = [ Label('Выберите тип отделки:'), ComboBox('fl_type', floor_type_options), Label('Введите привязку пола к уровню :'), TextBox('h_offset', base_offset="50.0"), CheckBox('checkbox1', 'Брать смещение пола из свойств помещения'), CheckBox('checkbox2', 'Вырезать отверстия'), Label('Вырезание отверстий работает корректно'), Label('при выборе только одного помещения'), Button('Select') ] form = FlexForm('Создать отделку пола', components) win = form.show() if win == False: sys.exit() #Get the ID of floor type floor_type_id = form.values['fl_type'].Id if form.values['h_offset'] != "": offset3 = float(form.values['h_offset'])
pass components = [ Label('Cut Elements:'), ComboBox( 'cut_element', { 'Sàn': 'floor', 'Cột': 'column', 'Dầm': 'beam', 'Tường': 'wall', 'Generic Model': 'generic_model', }), Separator(), Label('Elements to join:'), CheckBox('join_floor', 'Sàn'), CheckBox('join_column', 'Cột'), CheckBox('join_beam', 'Dầm'), CheckBox('join_wall', 'Tường'), 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()
from pyrevit import revit, DB, script, forms from operator import itemgetter from rpw.ui.forms import (FlexForm, Label, ComboBox, TextBox, TextBox, Separator, Button, CheckBox, Alert) output = script.get_output() dim_terms = ['width', 'depth', 'height', 'length'] bool_terms = ['add', 'modify', 'starter', 'adder', 'vis', 'viz'] standard_size_params = ['STD_Widths', 'STD_Depths', 'STD_Heights'] # ensure active document is a family document forms.check_familydoc(revit.doc, exitscript=True) components = [Label('Choose Parameters'), CheckBox('checkbox1', 'Price', default=True), CheckBox('checkbox2', 'Weight', default=True), CheckBox('checkbox3', 'Product Code'), Separator(), Label('Dimensions'), CheckBox('checkbox4', 'Standard Sizes'), CheckBox('checkbox5', 'Min & Max Sizes'), Button('Select')] form = FlexForm('CSV to Formulas', components) if form.show(): priceChecked = form.values['checkbox1'] weightChecked = form.values['checkbox2'] codeChecked = form.values['checkbox3'] standardChecked = form.values['checkbox4']
positions_list = [ "Bottom Left", "Bottom Centre", "Bottom Right", "Top Left", "Top Centre", "Top Right" ] # construct rwp UI components = [ Label("Pick Text Style"), ComboBox( name="textstyle_combobox", options=text_style_dict, ), Label("Pick Text Position"), ComboBox(name="positions_combobox", options=positions_list), Separator(), CheckBox('show_p_name', 'Show Parameter Name'), Button("Select") ] form = FlexForm("Select", components, exit_on_close=True) select = form.show() if select: text_style = form.values["textstyle_combobox"] chosen_position = form.values["positions_combobox"] show_p_name = form.values["show_p_name"] else: sys.exit() #dims and scale scale = float(view.Scale) / 100 text_offset = 2 * scale
import System.Windows defaultParameter = False parameters = revitron.ParameterNameList().get() selection = revitron.Selection.get() if 'Family and Type' in parameters: defaultParameter = 'Family and Type' components = [ Label('Parameter Name'), ComboBox('parameter', parameters, default=defaultParameter), 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
components = [ Label("Select Titleblock"), ComboBox(name="tb", options=sorted(ui.titleblock_dict), default=database.tb_name_match(ui.titleblock, doc)), Label("Sheet Number"), TextBox("sheet_number", Text=ui.sheet_number), Label("Crop offset" + unit_sym), TextBox("crop_offset", Text=str(ui.crop_offset)), Label("Titleblock (internal) offset" + unit_sym), TextBox("titleblock_offset", Text=str(ui.titleblock_offset)), Label("Layout orientation"), ComboBox(name="layout_orientation", options=ui.layout_orientation, default=ui.layout_ori), CheckBox("el_rotation", 'Rotate elevations', default=ui.rotated_elevations), CheckBox("el_as_sec", 'Elevations as Sections', default=ui.el_as_sec), Label("Titleblock orientation"), ComboBox(name="tb_orientation", options=ui.tblock_orientation, default=ui.titleblock_orientation), Separator(), Label("View Template for Plans"), ComboBox(name="vt_plans", options=sorted(ui.viewplan_dict), default=database.vt_name_match(ui.viewplan, doc)), Label("View Template for Reflected Ceiling Plans"), ComboBox(name="vt_rcp_plans", options=sorted(ui.viewplan_dict), default=database.vt_name_match(ui.viewceiling, doc)), Label("View Template for Elevations"),
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) #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
"墙": DB.BuiltInCategory.OST_Walls, "结构框架": DB.BuiltInCategory.OST_StructuralFraming } FamilyTemplateNames = {"常规模型": "Metric Generic Model.rft"} #信息输入部分 components = [ #Label('材质'), #ComboBox('Material', Materials_options), Label('类型'), ComboBox('FamilyTemplateName', FamilyTemplateNames), Label('AssemblyCode'), TextBox('AssemblyCode', Text="14-10"), Label('是否为结构框架'), CheckBox('isFraming', 'isFraming'), Button('确定') ] form = FlexForm('结构', components) form.show() Value = form.values isFraming = Value['isFraming'] assemblyCode = Value['AssemblyCode'] FamilyTemplateName = Value['FamilyTemplateName'] _familyTemplatePath = app.FamilyTemplatePath #######Get Element Slids
import System.Windows defaultParameter = False parameters = revitron.ParameterNameList().get() selection = revitron.Selection.get() if 'Family and Type' in parameters: defaultParameter = 'Family and Type' components = [ Label('Parameter Name'), ComboBox('parameter', parameters, default=defaultParameter), 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)
for element in elements } # 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