Running a script

Scripts allow you to run and control SPACE GASS from another program external to SPACE GASS.


Scripts are not for running an external program from within SPACE GASS. For that you should refer to Running a Macro.


A script is simply a text file that contains a list of commands that SPACE GASS will automatically execute one-by-one. The script file can be located anywhere, and its name and location must be specified in the command line when SPACE GASS is started.


For example, a command line option of -s "c:\scripts\myscript.txt" would load the myscript.txt script file from the c:\scripts folder. Note that the double quotes (" ") can be omitted if this option is at the end of the target field.


You can use the built-in script editor to create a script file. Alternatively, you can manually create a script file using a text editor or you can write a program that will create the script file and hence be able to control SPACE GASS automatically.


The commands in the script file allow you to select many of the SPACE GASS menu items, however currently only the job open/close, import, export, static analysis, buckling analysis, dynamic frequency analysis, steel member design and exit functions will bypass their input dialogs when in script mode. All of the other functions will display their normal dialogs and messages and then continue with the script when you have responded to them.


Any error messages will be displayed and cause the script mode to be terminated. If "Silent" mode is selected then any information messages or warnings will be added to the log file and will not cause the script to pause.


If you want to run SPACE GASS normally, ensure that the -s script file option does not exist in the target field of the SPACE GASS shortcut that you use to start SPACE GASS, otherwise SPACE GASS will go into script mode and will execute all the script commands rather than allowing you to control it normally.


Note that any script files created for SPACE GASS 12.91 or earlier versions will not work with SPACE GASS 14 or later versions. You would need to manually convert them to the new format or re-create them from scratch using the in-built script editor.


If you want to create script files manually, you should use the script editor to generate a sample script file and then open it with a text editor and use it as a pattern for your own script files.


You can open the script editor by selecting "Script Editor" from the File menu.



A script can be created by double-clicking the desired items from the menu on the left to have them added to the panel on the right. You can change the script order by simply dragging items up or down in the panel on the right or using the buttons.


You can deactivate any script command by selecting it and then clicking the Activate/Deactivate button. This places a # character at the start of the line in the script file and bypasses it when the script executes. The Activate/Deactivate button can also be used to reactivate a deactivated script command.


The "Window State" options allow you to run the script with normal visibility, minimized (not visible) or maximized (full screen). If you don't want to see SPACE GASS at all then you should select "Minimized" and "Silent". For no visibility you may also want to launch SPACE GASS hidden using the -min command line switch.



The "Control" options allow you to further control how SPACE GASS behaves when running a script. "Silent" bypasses all messages, "Close at End" instructs SPACE GASS to shut down at the end of the script, and "Save to Log" saves the script progress messages and other information that would normally be displayed into a log file.



Once you have created a script file, you can test it by clicking the "Run Script" button. Once the script is working correctly you can run it via a command line option when you start SPACE GASS. For example, a command line option of -s "c:\scripts\myscript.txt" would load the myscript.txt script file from the c:\scripts folder, start SPACE GASS and execute the script commands.


If you have set up your own program that automates the process of generating a script file, running it, modifying the script file (or generating a new one), running it again, and repeating the process multiple times, your program will need to know when the current script has finished so that it can proceed with the next one. One recommended method for doing this is to place a "Write File" action at the end of the script. When your controlling program detects the presence of the file created by the "Write File" action then it will know that the script has ended. It is a good idea to add a small wait period of 100 milliseconds or so after it detects the presence of the file to give SPACE GASS time to properly close the script file before your controlling program modifies or replaces it.


Note that when you start a new job or exit SPACE GASS in a script file, any changes to the current job will be abandoned. If you wish to save the changes then you should include a Save or Save-As script command before the New Job or Exit commands.