Commands Objects and the Mechanical APDL Solver

The commands issued by the Commands objects affect the solution, however; they do not alter settings within Mechanical. This section describes how the following characteristics and requirements apply to Commands object when used with the Mechanical APDL solver.

Text and Units

Command text cannot contain characters outside of the standard US ASCII character set due to the fact that this text will propagate into the Mechanical APDL application input files and must follow the rules set aside for the Mechanical APDL application commands and input files. Use of languages other than English for the command text may cause erratic behavior. The Mechanical APDL application commands should not be translated.

Make sure that you use consistent units of measure throughout your simulation. The application does not convert units of measure in the Commands objects. Unit-dependent entries do not get converted if you make unit system changes in the analysis. Changes of this nature can lead to inaccurate results.

Commands object input for magnetostatic analyses must be in MKS units (m, Kg, N, V, A).

Step Selection Mode

The Step Selection Mode property displays when you:

For stepped analyses, this property enables you to specify which sequence steps are to process the Commands object. The choices are: First, Last, All, and By Number. If you select the By Number option, the property Step Number displays. You use this property to specify the step during which your command(s) will execute.

For a Harmonic Response analysis, you can specify the solution phase (All, Modal Solution, Harmonic Solution, or Harmonic Expansion) during which the command snippet will execute.

Point Selection Mode

The Point Selection Mode property displays in the Details view of a Commands object that is inserted under a Modal environment when the Campbell Diagram property is set to On (Analysis Settings>Rotordynamics Controls). This property enables you to specify which Modal Points, as they correspond to the Campbell Diagram, are to process the Commands object. Options include:

User Convenience Parameters

When a project is saved in workbench, the application’s project file management creates a directory/folder structure. The generated folders house a variety of files, such as input or result files. As a part of this structure, there is a folder created that is named user_files.

The Mechanical APDL solver input file, ds.dat, includes the following parameter (variable):

_wb_userfiles_dir(1)

The value of this parameter equals the path to the user_files directory.

You can use this parameter with the Commands Object and perform file operations in the Mechanical APDL language. For example, by specifying this parameter, you can copy result files to the user_files directory.

For a more specific example, accessing external user macros located in this directory might be done using the following Mechanical APDL command:

/INPUT, '%_wb_userfiles_dir(1)%file_aqld1001.dat'

For additional information on the Mechanical APDL Command language, see the Mechanical APDL Command Reference.

Output Parameters: Using Parameters Defined in Solution Command Objects

For Commands objects at the Solution level, an output search prefix can be used to scan the text from a resulting solution run. After you choose Search Parameters, values for the Mechanical APDL application parameter assignments are returned that match the output search prefix. The default output search prefix is my_. Changing the prefix at any time causes a rescan of the text for a matching list. After a SOLVE, the Mechanical APDL application parameters that are found to match the prefix are listed in the Details view for the Commands object with their values. This procedure is illustrated in the demonstration below. Parameters created using Commands objects can be used in Design Exploration.


Note:  If you have parameterized an output parameter in the Commands object, you cannot edit the command text. You need to remove the parameters to edit the text


The following demo is presented as an animated GIF. View online if you are reading the PDF version of the help. Interface names and other components shown in the demo may differ from those in the released product.

Mechanical APDL Application Plots in Mechanical

You can view Mechanical APDL application plots in Mechanical that result from using Commands objects. The Mechanical APDL application plots are returned from Mechanical APDL to display in the Worksheet. This feature is useful if you want to review result plots that are available in the Mechanical APDL application but not in Workbench, such as unaveraged stress results or contact results only on a particular region.

To View the Mechanical APDL Application Plots in Mechanical:

  1. Create one or more Commands objects.

  2. Direct plot(s) to PNG format.

  3. Request plots in the Commands objects.

  4. Make sure that there is at least one Commands object under Solution in the tree.

  5. Solve. Requested plots for all Commands objects are displayed as objects under the first unsuppressed Commands object that appears below Solution.


Note:  The Mechanical APDL application PowerGraphics mode for displaying results is not compatible with Commands objects. No results will be produced in this mode. If your command list includes the PowerGraphics mode (/GRAPH,POWER), you must switch to the Full mode by including /GRAPH,FULL at the end of the list.


Presented below is an example of a Commands object used to create two plots, one for unaveraged stress, and one for element error.

!   Commands inserted into this file will be executed immediately after the ANSYS /POST1 command.
!   If a SET command is issued, results from that load step will be used as the basis of all 
!   result objects appearing in the Solution folder.

set,last      ! read the last data set
/show,png     ! output to png format

/gfile,650    ! adjust size of file

/edge,1,1     ! turn on element outlines
/view,,1,1,1  ! adjust view angle

ples,s,eqv    ! plot unaverage seqv
ples,serr     ! plot element error

The Mechanical APDL application plots are shown below.

Unaveraged Stress Result:

Element Error Result:

Commands Objects and Materials

  1. When using Commands objects, do not change the material IDs for elements. This will cause the results retrieval form the Mechanical APDL application to Workbench to malfunction.

  2. Instead of adding one large Commands object to change all of the materials, add individual Commands objects under each part. That way you will be able to reference the “matid” in the Commands object for the material ID of the elements that make up the part. You will also only need to enter the adjusted coefficient of thermal expansion and not the other materials.

  3. Use the Worksheet view of the Geometry object to determine which materials are assigned to specific parts.

  4. Click the right mouse button on a selected item in the Worksheet view, then choose Go To Selected Items in Tree to add Commands objects.

  5. Copy and paste Commands objects from one part to another that have the same material assignment.

Mechanical and Mechanical APDL Applications Conflicts

In order to utilize the Command object feature and execute Mechanical APDL application commands in Mechanical, you must have a thorough understanding the use of Mechanical APDL Commands. Moreover, you need to understand that there are times when Mechanical APDL commands may conflict with the internal settings in Mechanical and as a result adversely affect your solution values.

The following are some common conflicts that could arise:

Using Mechanical APDL Commands in the Mechanical application requires a working knowledge and experience with Mechanical APDL Commands and therefore, it is your responsibility to make sure that any command that you are issuing does not conflict with any existing Mechanical application requirement.


Release 18.2 - © ANSYS, Inc. All rights reserved.