API Structure and Hierarchy Overview

The Autodesk Simulation CFD Scripting language uses elements that are common to many programming languages. The language is based on a series of classes. Each class has its own properties and methods. Python is conceptually similar to C++, but has certain unique syntactic and formatting elements.

This topic discusses some of the concepts of Python that are essential for using the Autodesk Simulation CFD API.

A general resource is the Python Programming Language Official Web site: http://python.org/.

Modules

The top-level API structure relates directly to the Autodesk Simulation CFD workflow. Functionality is divided into four distinct modules:

DC

DSE

Results

Setup

To access functionality within a module, you must call it at the beginning of the script. It is good practice to initialize all modules to ensure that all necessary functionality is available. To do this, include the following lines at the beginning of your scripts:

from CFD import Setup

from CFD import Results

from CFD import DSE

from CFD import DC

API Hierarchy

Each module contains a series of classes. Each class contains methods.

Class Structure

The API class structure has a specific hierarchy. Object is the top-level class, and has several classes below it. The Container and SummaryObject classes have child classes of their own. The complete class structure is shown:

To call a specific static function, use the following structure:

Module.class.function

For example, to define a variable called study as the current design study, use this command:

study = Setup.DesignStudy.Create()

This calls the Create function, which is in the DesignStudy class, which is in the Setup module.

Note: The Object class (which is owned by the Setup module) contains classes with entities that belong to the other modules as well. Keep in mind that classes and objects are different things. The CutPlane class is shown in the hierarchy under the Object class, which allows it to inherit all of the members of the Object class. However, in this sense, a cutplane is an abstraction, and refers to a type of entity. When a cut plane is created in a model, it is real object, and not an abstraction. Therefore, it is part of the Results module.

Inheritance

Classes in the API contain member functions that enable specific functionality. Sub-classes contain unique member functions, and also inherit the member functions of the parent class.

This concept is called inheritance. It is an important concept of the API.

For example, the SummaryPart class contains its members, plus the members in the SummaryObject class, and those in the Object class:

To see all of the members accessible from a class, click List of all members on the API Programming Reference page that describes the class. Here is the list for the SummaryPart class:

Note: The members unique to the child class are not owned by the parent class.

Function Types

The two primary types of functions owned by most classes are Static Public Member Functions and Public Member Functions.

Static Public Member Functions

Static public member functions can be used if a particular instance of the class does not currently exist. Many static public member functions are used for creating entities.

For example, in the DesignStudy class, Create is a static member function used for creating or getting the current design study. The command to get the design study object is:

Setup.DesignStudy.Create()

Public Member Functions

Public member functions perform actions on or to an actual object that already exists.

For example, in the DesignStudy class, Save is a public member function that acts on a design study that already exists. (It is not possible to save a design study that does not exist.)

Related Topics

Application Programming Interface (API)

API Programming Reference

Script Editors