A nice feature to add to the file save dialog would be to provide a default file name depending upon the configuration selected. Solid Edge does this when saving a new file by suggesting a default file name like Part1.par, asm2.asm, etc.
To do this, add the line in bold as shown below for the Save Part button:
saveDialog.Title = "Save Part Configuration As..."
saveDialog.Filter = "Save Part Configuration|*.par"
saveDialog.FileName = lstShaft.SelectedItem.ToString + " 1"
This simply means, take the text of the selected item in the listbox and add 1 to it and use it as the default file name to save the configuration.
So when the Shaft with Hole configuration is picked, the default file name would appear as shown besides.
Using the + sign to add strings is a powerful feature of VB.Net. Invest some time in exploring strings in VB.Net at this suggested site. This knowledge will come in handy in many situations while automating Solid Edge.
The file dialog used here is a VB.Net feature. Solid Edge provides its own flavour of the File Save dialog which can be accessed using the GetSaveAsFileName function of the application object. Thus it can be accessed as below:
Open the Solid Edge installation folder and in the SDK folder open the sesdk.chm help file.
On the search tab, type in GetSaveAsFileName and click List Topics.
In the Select topic: list, double-click GetSaveAsFileName. The SE API documentation has detailed information on the various arguments and also a sample program on the usage of this method, hence it won't be discussed here again.
These were the two items in the TODO list from previous post.
In the next part of the Automation series:
1. Revisit parametric parts and how to parametrically control parts from within an assembly using peer variables via VB.Net code.
2. Read in current values of variables so the user can tweak them from the current value - this is in response to a question on the Solid Edge DEV forum.