Ansys Workbench Objects

Ansys Workbench objects fall into two general categories: data containers and data entities. The basic process for operating on these objects is:

  1. Query for either a data container or data entity objects. Queries are implemented as methods on both data container and data entity objects, and they most often start with Get (such as GetFiles, GetSystem, GetComponent). These methods return references to objects that are assigned to variables. The variables can then be used to access object properties and methods. To illustrate this process, consider the Design of Experiments (DOE) data container that includes a data entity for the DOE model, which in turn contains a data entity for the input parameters. To query the input parameter object, first query the DOE model from the data container, and then query the input parameter from the DOE model:

    DOEModel = DOEDataContainer.GetModel()      
    InputParameter = DOEModel.GetParameter(Name="P1")
    

    In most instances, the variable for a data reference will be reused later in the journal or script so that queries do not need to be re-executed. However, there are some instances (such as System Coupling variables), where re-executing the query can clarify the context that is used to access the object. In those situations, journal variables are not reused and queries are generated each time an object is referenced.

  2. Interrogate and modify object properties. If the query returns a reference to a data entity, you can interrogate its properties and modify those that are not identified as Read Only in the reference section of this guide. Properties are accessed by appending a dot and the property name to the variable assigned to the object reference. For example, once a reference to an input parameter is obtained, you can modify its classification (or Nature Property) to reflect that it is a continuous or discrete parameter.

    inputParameter.Nature = "NatureContinuous"
  3. Call methods on objects. In addition to properties, most objects provide methods that operate on internal data. To call a method on an object, append a dot, the method name, and a comma-separated argument list in closed parentheses. A method's required and optional arguments are also documented in the reference section of this guide. Continuing the input parameter example, you can specify a restricted set of manufacturable values for a parameter by calling the AddLevels method on the input parameter object and by constructing a list of values and assigning it to the Levels argument.

    inputParameter.AddLevels( Levels=["65", "70", "75", "80"])

Typical examples are provided in Usage Examples. These examples demonstrate how to query objects and how to invoke methods on those objects for the desired result. Refer to the reference section in this guide for a complete list of all available data container objects and their respective data entities, methods, properties, and arguments.