Thursday, 27 November 2014

Making of PacEdge Part 07

...continued from part 6

Further check if the active file selection mode is MultiplFiles or AllFromfolder:

If FSelMode = FileSelectionMode.MultipleFiles Then

PacEdge provides two ways of adding files to the TreeList:

  1. Using a File Open dialog with multiple file selection feature.


  1. A standard Folder Browser dialog.


The FileSelectionMode enum declared as below facilitates to switch between these modes and the RadioButton controls Pick Files and Pick Folder let the user switch the mode:


When the Pick Files options is selected, the dlgOpen OpenFileDialog control is set to provide three file filters to the user:

dlgOpen.Filter = "Solid Edge Part Files|*.par|Solid Edge Sheetmetal Files|*.psm|Solid Edge Part and Sheetmetal Files|*.par;*.psm"

The single string has 3 filters one each for Part and Sheetmetal files and the third one that filters both these file types together.

The filters for Part, Sheetmetal and combined files are separated by the same pipe (|) symbol that also separates the display and filter parts of the filter itself.


The third filter is an interesting bit in that it is a composite filter that filters out both .PAR and .PSM files at same time. The actual filter has a semi-colon (;) between the two extensions in the actual filter part:

Solid Edge Part and Sheetmetal Files|*.par;*.psm

So *.par;*.psm together form a single filter.

Another important property set for the File Open dialog is the Multiselect

dlgOpen.Multiselect = True

This allows user to pick files by dragging a window around files just like picking multiple objects in Solid Edge.


Optionally the user can keep the Ctrl or Shift keys pressed while picking multiple files using the mouse. In the same way a picked file can be picked again to un-pick it.

Notice how the files selected are all listed in the file name box below as strings separated by a space.

These files are stored in the FileNames array of the File Dialog and can be retrieved in an array sParAndPsmFiles()


Dim sParAndPsmFiles() As String = dlgOpen.FileNames

Note that the FileNames array is a separate property from the FileName property which stores just a single filename picked by the user when Multiselect is set to False.

With Multiselect set to True and the scenario when user picks just one file still stores the single file’s name into the FileNames array.

The CheckBoxes PAR and PSM meanwhile help in setting the default filter from among the three discussed earlier:

If chkPAR.Checked = True And chkPSM.Checked = False Then

  dlgOpen.FilterIndex = 1

ElseIf chkPAR.Checked = False And chkPSM.Checked = True Then

  dlgOpen.FilterIndex = 2

ElseIf chkPAR.Checked = True And chkPSM.Checked = True Then

  dlgOpen.FilterIndex = 3

End If

Of the 3 filters, only the appropriate is set as the default depending upon the checked condition of the PAR and PSM check boxes as evident in the code snippet above.

However, the filter can be changed at runtime which may be different from the one set with the PAR or PSM check boxes. For this, the filters should not be set and filtered but the filters should be created in the CheckBoxes PAR and PSM’s CheckedChange events.

Currently this is not implementing since a user as well might realize after selecting a bunch of Part files that few more PSM files also need to be picked. The multiple picking facility though addresses this need.

Continued to part 8... 

Index of all Solid Edge Tips, Tutorials and Videos...