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 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 addFields(components, fields): for field in fields: if field == '---': components.append(Separator()) else: key = revitron.String.sanitize(field) components.append(Label(field)) components.append(TextBox(key, Text=config.get(key))) return components
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 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') ]
def CreateForm(self): # Create Menu systemOptions = self.availableSystems heightOptions = self.heightOptions divisionTypeOptions = self.divisionOptions widthOptions = self.panelWidthOptions # Make sure default values are set if not self.configObj.currentConfig["selectedSystem"] in systemOptions.values(): defaultSystem = systemOptions.keys()[0] else: defaultSystem = systemOptions.keys()[systemOptions.values().index(self.configObj.currentConfig["selectedSystem"])] if not self.configObj.currentConfig["headHeight"] in heightOptions.values(): defaultHeight = heightOptions.keys()[0] else: defaultHeight = heightOptions.keys()[heightOptions.values().index(self.configObj.currentConfig["headHeight"])] if not self.configObj.currentConfig["spacingType"] in divisionTypeOptions.values(): defaultDivOption = divisionTypeOptions.keys()[0] else: defaultDivOption = divisionTypeOptions.keys()[divisionTypeOptions.values().index(self.configObj.currentConfig["spacingType"])] if not self.configObj.currentConfig["storefrontPaneWidth"] in widthOptions.values(): defaultWidthOption = widthOptions.keys()[0] else: defaultWidthOption = widthOptions.keys()[widthOptions.values().index(self.configObj.currentConfig["storefrontPaneWidth"])] self.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')]
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), 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
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)
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)