The Autodesk Simulation CFD Application Programming Interface (API) provides ways to work with Autodesk Simulation CFD functionality that are not readily available in the user interface.
The API is a platform for customization, and can significantly benefit your design process. It is very flexible, and can be used for a wide variety of tasks. Here are a few examples of potential applications:
- Automate repetitive tasks normally performed in the user interface.
- Create custom tasks.
- Create custom results quantities.
- Output results in customized or specialized formats.
While the scope of API applications is very wide, it is not as well suited for automating graphically-interactive actions (such as dragging a results plane).
The API is based on the Python scripting language. Python has been widely accepted, and is both easy to use and flexible. Python has built-in connections with other technologies, including Microsoft® Office tools such as Excel, that make it an ideal "glue language." Autodesk Simulation CFD 2013 is distributed with Python version 2.7.
Two script editors are available for creating, editing, and running scripts. Use the editor in the UI for interacting with an open design study. Use the stand-alone utility for running existing scripts, mainly for running scripts as a batch process.
Click here for more details about the script editors.
Two Scripting Languages: Python scripting and QT Scripting
Python scripting and QT Scripting work in tandem for Autodesk Simulation CFD 2013. The choice of scripting language is based on the features you wish to automate.
- Use QT scripting to automate model setup.
- Use Python scripting to automate results extraction.
Note that going forward, all new functionality will be developed using Python scripting as QT scripting is phased out.
The API language reference is included in a separate documentation library included with the installation. To access it, navigate to the Help\API-Documentation sub-folder of your Autodesk Simulation CFD installation, and double click on index.html.
For detailed information about how to use the API Programming Reference, click here.
The Examples Library in the API Programming Reference contains multiple example scripts. Use these as a reference and starting point for your own scripts.
For a good introduction to the Python programming language and syntax, you should review the tutorials on the Python Programming Language Official Web site, http://docs.python.org/tutorial/.
The complete Python documentation is available by clicking here.
Customizing the User Interface with a Startup Script
The API can be used to add menu items or to customize the user interface. To automatically run a script every time Autodesk Simulation CFD is started, perform the following steps:
- Create the script, and name it: "UserStartupScript.py"
- Save it to the account\AppData\Local\Autodesk\Simulation CFD 2013 folder. (Note: account is the name of the user account in which the startup script will run automatically.)
The example script called ribbon.py describes how to add a menu to the user interface.
Because Python has connects to MS Office tools, it is relatively easy to output data in standard formats for presentation or reuse in other software tools. The Autodesk Simulation CFD API uses the COM protocol to make calls to the MS Office API.
For more information about using the API with Excel, click here.