def __init__(self, form): """Set up the initial dialog and connect Buttons to actions.""" self.form = form # find current viewport currentViewport = session.viewports[session.currentViewportName] # assign odb file from current viewport self.odbFile = currentViewport.displayedObject # get file name and path self.odbFileNameFull = self.odbFile.path AFXDataDialog.__init__(self, form, "Create Tensor Field", 0, DIALOG_ACTIONS_SEPARATOR) FXLabel(self, "This plugin creates a tensor from state variables.") nvis = 0 self.nameTextField = AFXTextField(self, 35, "Field name:") self.descTextField = AFXTextField(self, 35, "Description:") variables = [] for var in currentViewport.odbDisplay.fieldVariables.variableList: if var[5] == "scalar": variables.append(var[0]) nvis = len(variables) self.s1combo = AFXComboBox(self, 0, nvis, "Component 11:") self.s2combo = AFXComboBox(self, 0, nvis, "Component 22:") self.s3combo = AFXComboBox(self, 0, nvis, "Component 33:") self.s4combo = AFXComboBox(self, 0, nvis, "Component 12:") self.s5combo = AFXComboBox(self, 0, nvis, "Component 23:") self.s6combo = AFXComboBox(self, 0, nvis, "Component 31:") self.framecombo = AFXComboBox(self, 0, nvis, "Frames:") for variable in sorted(variables): self.s1combo.appendItem(variable) self.s2combo.appendItem(variable) self.s3combo.appendItem(variable) self.s4combo.appendItem(variable) self.s5combo.appendItem(variable) self.s6combo.appendItem(variable) self.framecombo.appendItem('All') self.framecombo.appendItem('First') self.framecombo.appendItem('Last') self.s1combo.setMaxVisible(10) self.s2combo.setMaxVisible(10) self.s3combo.setMaxVisible(10) self.s4combo.setMaxVisible(10) self.s5combo.setMaxVisible(10) self.s6combo.setMaxVisible(10) self.framecombo.setMaxVisible(3) self.appendActionButton("Create Field", self, self.ID_CLICKED_APPLY) self.appendActionButton(self.DISMISS) FXMAPFUNC(self, SEL_COMMAND, self.ID_CLICKED_APPLY, CreateSymmTensor.doCustomChecks) FXMAPFUNC(self, SEL_COMMAND, self.ID_WARNING, CreateSymmTensor.onCmdWarning)
def __init__(self, form): """Set up the initial dialog and connect Buttons to actions.""" self.form = form self.file_name = AFXStringTarget() AFXDataDialog.__init__(self, form, "Export MDB", 0, DIALOG_ACTIONS_SEPARATOR) FXLabel( self, "This plugin exports the current part or assembly with meshio.") hf_file = FXHorizontalFrame(self) self.sourceTextField = AFXTextField(hf_file, 20, "Export to:") self.sourceButton = FXButton(hf_file, "Select File", None, self, self.ID_CLICKED_FILE_BUTTON) self.appendActionButton("Export", self, self.ID_CLICKED_APPLY) self.appendActionButton(self.DISMISS) FXMAPFUNC(self, SEL_COMMAND, self.ID_CLICKED_APPLY, ExportMDB.export) FXMAPFUNC(self, SEL_COMMAND, self.ID_CLICKED_FILE_BUTTON, ExportMDB.select_file)
def __init__(self, form): def atoi(text): return int(text) if text.isdigit() else text def natural_keys(text): ''' alist.sort(key=natural_keys) sorts in human order http://nedbatchelder.com/blog/200712/human_sorting.html (See Toothy's implementation in the comments) ''' return [atoi(c) for c in re.split(r'(\d+)', text)] """Set up the initial dialog and connect Buttons to actions.""" self.form = form # find current viewport currentViewport = session.viewports[session.currentViewportName] # assign odb file from current viewport self.odb = currentViewport.displayedObject # get file name and path self.odbFileNameFull = self.odb.path self.file_name = AFXStringTarget() AFXDataDialog.__init__(self, form, "Export ODB", 0, DIALOG_ACTIONS_SEPARATOR) FXLabel(self, "This plugin exports the ODB with Meshio.") self.variables = [] for var in currentViewport.odbDisplay.fieldVariables.variableList: self.variables.append(var[0]) self.variables.sort(key=natural_keys) hf_selectors = FXHorizontalFrame(self) gb_instances = FXGroupBox(hf_selectors, "Instance", FRAME_GROOVE) gb_instances_label = FXVerticalFrame(gb_instances, FRAME_THICK) self.instlist = AFXList(gb_instances_label, 10, None, 0, LIST_BROWSESELECT | HSCROLLING_OFF) for instance in self.odb.rootAssembly.instances.keys(): self.instlist.appendItem(instance) gb_frames = FXGroupBox(hf_selectors, "Frame", FRAME_GROOVE) gb_frames_labels = FXVerticalFrame(gb_frames, FRAME_THICK) self.framelist = AFXList(gb_frames_labels, 10, None, 0, LIST_BROWSESELECT | HSCROLLING_OFF) for step in currentViewport.odbDisplay.fieldSteps: step_name = step[0] frames = step[7] for i, f in enumerate(frames): self.framelist.appendItem("%s: %d (%s)" % (step_name, i, f)) gb_variables = FXGroupBox(hf_selectors, "Variables", FRAME_GROOVE) gb_variables_label = FXVerticalFrame(gb_variables, FRAME_THICK) self.varlist = AFXList( gb_variables_label, 10, None, 0, LIST_BROWSESELECT | HSCROLLING_OFF | LIST_MULTIPLESELECT, ) for i, var in enumerate(self.variables): self.varlist.appendItem(var, None, i) hf_file = FXHorizontalFrame(self) self.sourceTextField = AFXTextField(hf_file, 20, "Export to:") self.sourceButton = FXButton(hf_file, "Select File", None, self, self.ID_CLICKED_FILE_BUTTON) self.check_deform = FXCheckButton(self, "Export deformed geometry.") self.check_deform.setCheck(state=True) self.appendActionButton("Export", self, self.ID_CLICKED_APPLY) self.appendActionButton(self.DISMISS) FXMAPFUNC(self, SEL_COMMAND, self.ID_CLICKED_APPLY, ExportODB.export) FXMAPFUNC(self, SEL_COMMAND, self.ID_CLICKED_FILE_BUTTON, ExportODB.select_file)