Drive the CAD User Interface directly from the DBWorks / DBInventor scripting

<< Click to Display Table of Contents >>

Navigation:  Programming Mechworks PDM > DBWCommandShell > Examples >

Drive the CAD User Interface directly from the DBWorks / DBInventor scripting

Description

This script shows a manner to export files from a DXF/DWG/IGES/STEP/etc. format even though it maintains the DBWorks/DBInventor SaveAs active.

Example for SolidWorks

The document must be already opened in SW

' How to drive the SW User Interface directly from the DBWorks scripting ...

' Author: C.Ettorre
' 20040924
'
'
' main application name: change it as per your needs
'
const cadApplicationName = "SolidWorks 2005"
Sub Main()
 DBWInit(TRUE)
 DBWShell( "TrackEvents 0" )
 audbws = DBWGetOption("ALWAYS_USE_DBWORKS_SAVE_AND_SAVEAS")
 DBWSetOption "ALWAYS_USE_DBWORKS_SAVE_AND_SAVEAS","0"
 set WshShell = CreateObject("WScript.Shell")
 ' no SW api is available for driving directly the SW User Interface Save As ...
 ' the sent keys will be received by the application only when the following popup dialog will be displayed
 WshShell.AppActivate cadApplicationName
 WshShell.SendKeys "%FA"
 'this popup message is MANDATORY; removing it, it will cause the mechanism to not work as expected ...
 ok = WshShell.Popup("Please select ONLY file types different\nfrom the native CAD format.\nPress OK to continue ...",1,"Exporting using SW Save As ...",0)
 DBWSetOption "ALWAYS_USE_DBWORKS_SAVE_AND_SAVEAS",audbws
 DBWShell( "TrackEvents 1" )
End Sub

Example for Inventor

' How to drive the Inventor User Interface directly from the DBWorks scripting ...

' Author: C.Ettorre
' 20051014
'
' main application name: change it as per your needs
'
const cadApplicationName = "Autodesk Inventor 10"
Sub Main()
 DBWInit(TRUE)
 DBWShell( "TrackEvents 0" )
 DBWSetOption "ALWAYS_USE_DBWORKS_SAVE_AND_SAVEAS","0"
 set WshShell = CreateObject("WScript.Shell")
 WshShell.AppActivate cadApplicationName
 WshShell.SendKeys "%Fo"
 'this popup message is MANDATORY; removing it, it will cause the mechanism to not work as expected ...
 WshShell.Popup "Select a format for exporting",0,"DBInventor: exporting to other formats",0
 DBWSetOption "ALWAYS_USE_DBWORKS_SAVE_AND_SAVEAS","1"
 DBWShell( "TrackEvents 1" )
End Sub