In the command line, you typically begin a command by typing:
ExtAPI.
This stands for Extension API and is the gateway into the ACT API. Once you type the period (.), you are in the API. The ACT Console provides "smart" autocompletion, which means it takes syntax elements such as brackets or quotations marks into account. As you type in the command line, a scrollable list of suggestions is displayed above the command line. Each suggestion has an icon with a letter and color-coding.
A letter in a square icon describes the type of a member, such as P for property or M for method.
A letter in a circle icon describes the nature of the return type for a selected member, such as C for class or E for enumeration.
See Using Autocompletion in the ANSYS ACT Developer's Guide for more information about member types and return types.
After typing ExtAPI., DataModel is one
of the many member types shown in the list of suggestions. This property accesses the
Mechanical tree. When you place the mouse cursor over any suggestion in the list, the
tooltip provides information about it. Clicking a suggestion inserts it in the command
line, where you then type any string that might be required followed by a period to see
the next set of available suggestions.
In the command line, pressing Ctrl + ↑ gives you access to the previous command shown in the command history.
A step-by-step example follows for building a command that returns the volume for a specific part body:
ExtAPI. – Provides access to the API.
ExtAPI.DataModel. – Provides access to the
Mechanical tree.
ExtAPI.DataModel.GeoData. – Provides access
to the geometry attached to Mechanical for this session.
ExtAPI.DataModel.GeoData.Assemblies[0]. –
Provides access to the first assembly. Python starts counting at 0 rather
than 1.
ExtAPI.DataModel.GeoData.Assemblies[0].Parts[0].Bodies[0].
– Provides access to the first part and its first body.
ExtAPI.DataModel.GeoData.Assemblies[0].Parts[0].Bodies[0].Volume.
– Provides access to the volume for this body.
Pressing Enter after constructing this command returns the volume
of the first body in the GeoData hierarchy.
The next example shows how autocompletion helps you to construct the following command:
ExtAPI.DataModel.Project.Geometry.ElementControl = ElementControl.Manual
As you select the ElementControl property during command
construction, the suggestion tooltip indicates that you must get or set the enumeration
return type to ElementControl. Once you do this, the suggestion
tooltip prompts you to select either Manual or Program
Controlled.
While simple, these two examples demonstrate how you use the ACT Console to access information. If you understand these examples, you are well on your way to writing scripts for the Mechanical interface. Additionally, you can refer to Script Examples to see scripts for performing many different types of tasks in Mechanical.