This video is taken from the Scripting Learning Track on Ansys Innovation Courses.
Let's beging by looking at the script prompt.
You can run individual commands or call script files directly by entering them into the prompt.
The prompt is also where all output and error messages appear.
When you are developing a lengthy script or want to save a series of commands for future
use, it is a good idea to save the commands into a script file.
This is most easily done using the integrated script file editor.
You can press the "Run script" button to run the script file, or press F9 on the keyboard
to run the selected section only.
You can run any script file simply by typing the name of the file without the .lsf extension,
into the Script Prompt.
Script files can also be called from other script files, simply by including the name
of the script as a command in the other file.
For example, if you create the file myscript.lsf, you can run this file from the Script Prompt
by entering 'myscript.'
There are other places where script can be entered.
If you look at the model, which is the parent object for all the rest of the simulation
objects, you can see that there are tabs for setup script and analysis script.
You can define the parameters in the 'Variables' tab and use the setup and analysis script
tabs to setup the simulation objects in the object tree and analyze the simulation results
once it's run.
Similarly, scripts are also used in structure and analysis groups as we will see next.
There are three types of group objects: Container, Structure and Analysis.
The Container group is simply used for grouping objects together for organizational purposes;
therefore, it does not have any option for scripting.
The structure and analysis groups, on the other hand, allow you to use scripting inside
Analysis groups have both setup and analysis script tabs, as the parent object "model".
Structure groups are simpler since they are not used for analysis; thus, they only have
a setup script tab.
By making a good use of scripts in the various ways just mentioned, you can setup your simulations
efficiently and do advanced analyses of your simulation results.
When you are considering scripts for your simulation, it is always a good idea to check
the object library first.
It contains many frequently used structures and analysis tools, which you can insert in
your object tree for immediate use.
If you need a more complicated structure or advanced analysis that is not included in
the object library, it might still be worth starting with the available examples and modify
them instead of writing the script from scratch.