def get_output_directory(): folder_dialog = FolderBrowserDialog() folder_dialog.ShowNewFolderButton = True folder_dialog.Description = 'Output directory for R scripts' if folder_dialog.ShowDialog() != DialogResult.OK: return None return folder_dialog.SelectedPath
def Dialog_dir_backup(self): """ Ask user to use same directory as Revit file or Open a DialogBox to select destination folder manually.""" try: #>>>>>>>>>> Check if Revit file exists. file_exist = os.path.exists(doc.PathName) if file_exist: dialogResult = MessageBox.Show( "Would you like to save CAD files in the same folder as current Revit file?\n\n" + "Current file's path: " + str(doc.PathName), __title__, MessageBoxButtons.YesNo) if (dialogResult == DialogResult.Yes): #>>>>>>>>>> Saving folder is the same as Revit location doc_path = doc.PathName rvt_name = doc_path.split("\\")[-1] temp = len(doc_path) - len(rvt_name) doc_dir = doc_path[:temp] return doc_dir #>>>>>>>>>> CHOOSE SAVING DIR fileDialog = FolderBrowserDialog() fileDialog.Description = "Select folder for saving dwg files." fileDialog.ShowDialog() #>>>>>>>>>> SELECTED PATH dir_backup = fileDialog.SelectedPath if not dir_backup: alert("Backup path was not selected!\n Please try again.", title=__title__, exitscript=True) return dir_backup except: return None
def win_dialog_thread(arg): print(f"dialog_thread started") folder_dialog = FolderBrowserDialog() file_dialog = OpenFileDialog() title = arg.Dequeue() initial_folder = arg.Dequeue() print(f"title: {title}, initial_folder: {initial_folder}") folder_dialog.Description = title folder_dialog.SelectedPath = initial_folder folder_dialog_result = folder_dialog.ShowDialog() file_dialog_result = file_dialog.ShowDialog() selected_folder = folder_dialog.SelectedPath selected_file = file_dialog.FileName win_dialog_result = selected_folder, selected_file arg.Enqueue(win_dialog_result) print(f"win_dialog_thread completed, {win_dialog_result}")
def win_dialog_thread(arg): print(f"dialog_thread started") folder_dialog = FolderBrowserDialog() file_dialog = OpenFileDialog() title = arg.Dequeue() initial_folder = arg.Dequeue() print(f"title: {title}, initial_folder: {initial_folder}") folder_dialog.Description = title folder_dialog.SelectedPath = initial_folder folder_dialog_result = folder_dialog.ShowDialog() file_dialog_result = file_dialog.ShowDialog() selected_folder = folder_dialog.SelectedPath selected_file = file_dialog.FileName win_dialog_result = selected_folder, selected_file arg.Enqueue(win_dialog_result) print(f"win_dialog_thread completed, {win_dialog_result}")
def getCustomToolPropertyContent(): # Create a Grid my_Grid = WPFControls.Grid() # Add 2 Rows and 1 Column my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.ColumnDefinitions.Add(WPFControls.ColumnDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.ColumnDefinitions.Add(WPFControls.ColumnDefinition()) currRow = 0 # -- Horizontal sheet definition IDLbl = WPFControls.TextBlock() IDLbl.Text = "Hatching definition" WPFControls.Grid.SetRow(IDLbl, currRow) IDLbl.FontSize = 11 # Create label and input field currRow += 1 layerLbl = WPFControls.TextBlock() layerLbl.Text = " Trajec. spacing (mm): " WPFControls.Grid.SetRow(layerLbl, currRow) WPFControls.Grid.SetColumn(layerLbl, 0) global distanceLine distanceLine = WPFControls.TextBox() WPFControls.Grid.SetRow(distanceLine, currRow) WPFControls.Grid.SetColumn(distanceLine, 1) # Create label and input field currRow += 1 pointSpacing = WPFControls.TextBlock() pointSpacing.Text = " Point spacing (mm):" WPFControls.Grid.SetRow(pointSpacing, currRow) WPFControls.Grid.SetColumn(pointSpacing, 0) global pointSpacingValue pointSpacingValue = WPFControls.TextBox() WPFControls.Grid.SetRow(pointSpacingValue, currRow) WPFControls.Grid.SetColumn(pointSpacingValue, 1) # Type of angular cut currRow += 1 angleCutType = WPFControls.TextBlock() angleCutType.Text = " Angular cut:" WPFControls.Grid.SetRow(angleCutType, currRow) WPFControls.Grid.SetColumn(angleCutType, 0) # Create a Combo box global angleTypeSelection angleTypeSelection = WPFControls.ComboBox() item1 = WPFControls.ComboBoxItem() item1.Content = "Single angle" angleTypeSelection.Items.Add(item1) item2 = WPFControls.ComboBoxItem() item2.Content = "Incremental" angleTypeSelection.Items.Add(item2) item3 = WPFControls.ComboBoxItem() item3.Content = "Cycle through" angleTypeSelection.Items.Add(item3) angleTypeSelection.SelectedIndex = "0" WPFControls.Grid.SetRow(angleTypeSelection, currRow) WPFControls.Grid.SetColumn(angleTypeSelection, 1) #angleTypeSelection.SelectionChanged += HandleAngleSelection # Create label and input field currRow += 1 global angleLbl angleLbl = WPFControls.TextBlock() angleLbl.Text = " Angle (deg):" WPFControls.Grid.SetRow(angleLbl, currRow) WPFControls.Grid.SetColumn(angleLbl, 0) global angleValue angleValue = WPFControls.TextBox() WPFControls.Grid.SetRow(angleValue, currRow) WPFControls.Grid.SetColumn(angleValue, 1) # Create checkbox to ask for mesh currRow += 1 global meshCheck meshCheck = WPFControls.CheckBox() meshCheck.Content = "Mesh the layers for me" meshCheck.Height = 25 WPFControls.Grid.SetRow(meshCheck, currRow) WPFControls.Grid.SetColumn(meshCheck, 0) WPFControls.Grid.SetColumnSpan(meshCheck, 3) # Create a button currRow += 1 getDirectory = WPFControls.Button() getDirectory.Content = "Select directory to save" WPFControls.Grid.SetRow(getDirectory, currRow) WPFControls.Grid.SetColumn(getDirectory, 0) getDirectory.Height = 30 WPFControls.Grid.SetColumnSpan(getDirectory, 3) getDirectory.Click += HandleGetDir global dialog dialog = FolderBrowserDialog() dialog.Description = "Choose where to save trajectories" dialog.ShowNewFolderButton = True # Create a button currRow += 1 goSlice = WPFControls.Button() goSlice.Content = "Create hatching" WPFControls.Grid.SetRow(goSlice, currRow) WPFControls.Grid.SetColumn(goSlice, 0) goSlice.Height = 30 WPFControls.Grid.SetColumnSpan(goSlice, 3) # Link a function to the Button "Click" event # This function will be called every time the Button is clicked goSlice.Click += HandleApplyButton # Add the controls to the Grid my_Grid.Children.Add(IDLbl) my_Grid.Children.Add(layerLbl) my_Grid.Children.Add(distanceLine) my_Grid.Children.Add(pointSpacing) my_Grid.Children.Add(pointSpacingValue) my_Grid.Children.Add(angleCutType) my_Grid.Children.Add(angleTypeSelection) my_Grid.Children.Add(angleLbl) my_Grid.Children.Add(angleValue) my_Grid.Children.Add(getDirectory) my_Grid.Children.Add(meshCheck) my_Grid.Children.Add(goSlice) # Return the Grid return my_Grid
def get_folder(prompt): dlg = FolderBrowserDialog() dlg.Description = prompt res = dlg.ShowDialog() if res == DialogResult.OK: return dlg.SelectedPath
def getCustomToolPropertyContent(): # Create a Grid my_Grid = WPFControls.Grid() # Add 2 Rows and 1 Column my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.ColumnDefinitions.Add(WPFControls.ColumnDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.ColumnDefinitions.Add(WPFControls.ColumnDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) my_Grid.RowDefinitions.Add(WPFControls.RowDefinition()) #my_Grid.ColumnDefinitions.Add(WPFControls.ColumnDefinition()) currRow = 0 # Create input field currRow += 1 lbl01 = WPFControls.TextBlock() lbl01.Text = "Region diam. (mm):" WPFControls.Grid.SetRow(lbl01, currRow) WPFControls.Grid.SetColumn(lbl01, 0) global input01 input01 = WPFControls.TextBox() WPFControls.Grid.SetRow(input01, currRow) WPFControls.Grid.SetColumn(input01, 1) # Create checkbox to extend the weld bead currRow += 1 global chkBox01 chkBox01 = WPFControls.CheckBox() chkBox01.Content = "Calculate normal directions" chkBox01.Height = 20 WPFControls.Grid.SetRow(chkBox01, currRow) WPFControls.Grid.SetColumn(chkBox01, 0) chkBox01.IsChecked = System.Nullable[System.Boolean](True) #WPFControls.Grid.SetColumnSpan(chkBox01, 2) # Create a button currRow += 2 goButton = WPFControls.Button() goButton.Content = "Get trajectory from selected edge" WPFControls.Grid.SetRow(goButton, currRow) WPFControls.Grid.SetColumn(goButton, 0) goButton.Height = 30 WPFControls.Grid.SetColumnSpan(goButton, 2) # Link a function to the Button "Click" event # This function will be called every time the Button is clicked goButton.Click += HandleApplyButton global dialog dialog = FolderBrowserDialog() dialog.Description = "Directory where to save trajectories" dialog.ShowNewFolderButton = True #my_Grid.Children.Add(lbl01) #my_Grid.Children.Add(input01) my_Grid.Children.Add(chkBox01) my_Grid.Children.Add(goButton) # Return the Grid return my_Grid