Tuesday, 21 January 2014

Cust 27: File Dialogs: VB.Net Part 2

Note:

…continued from Part 1

Similarly, Solid Edge also has an API of its own to display the Solid Edge standard dialog:

image

To display this dialog from the Form, type the following for the Solid Edge File Dialog button:

   1:  Dim oDocRel As Object = Nothing
   2:   
   3:  sFileName = oApp.GetOpenFileName(SolidEdgeFramework.LinksUpdateOption.igNoLinksUpdate, "", SolidEdgeFramework.DocumentAccess.igReadOnly, _
   4:  SolidEdgeFramework.NotifyOption.igNotifyWhenAvailable, oDocRel, "Solid Edge Part files,*.par,Solid Edge Asm files,*.asm")
 
Check if the filename property is an empty string:
 

   1:  If sFileName <> String.Empty Then
   2:    oApp.Documents.Open(sFileName)
   3:  End If



The advantage of using the Inventor file dialog are the Preview, Options button and the ability to specify the project which lacks in the .Net file dialog.


Note the last argument which is the file filter and is a string separated by commas and not pipes like .Net.


The ShowSave method of the Solid Edge file dialog can be used to display the Solid Edge Save dialog which again has the advantage of over .Net’s file save dialog in that various Options can be accessed as shown below:


image


The method to display a Save dialog using .Net is also straight forward:


oApp.GetSaveAsFileName(


Note that when invoking the Solid Edge file dialogs from a Form, the focus has to switch to Solid Edge where the dialogs are displayed.


Another downside of using the Solid Edge file dialogs is Inventor should be running before displaying the dialog.


Full index of programming tutorials on this blog is here.


clip_image002_thumb1_thumb_thumbDrop a comment below if you need the Visual Studio project files and if you liked the depth of this discussion, similar in-depth techniques are discussed in cMayoCAD where you create your own, brand new, fully functional CAD system with scripting capabilities using a geometric modeling kernel.

Download the detailed course contents for cMayoCAD here.
cMayoCAD2