Creating Property Groups

This section focuses on the process of creating groups of properties.

The following methods are available:

Using <PropertyGroup> and <PropertyTable> Blocks

This section focuses on the process of creating groups of properties using <PropertyGroup> and <PropertyTable> blocks in the XML extension definition file.

The <PropertyGroup> and <PropertyTable> blocks are used to create groups of properties with a given caption. In this way, it is possible to manage dependencies between properties and to create worksheet views from a property.

  • The <PropertyGroup> block encapsulates a list of child properties under one group.

  • The <PropertyTable> block encapsulates a list of child properties under one table. Each child property creates a new column in the table. The user is able to control the line number of this table.

These functionalities are demonstrated in the extension AdvancedProperties.

The first example shows how to create a group of properties with a caption. The group can be collapsed or expanded by the user. The following figure shows the caption Simple group with caption.

 

This group is created with the following XML code:

<propertygroup name="Group1" caption="Simple group with caption" display="caption">
  <property name="Prop1" caption="Prop1" control="text" />
  <property name="Prop2" caption="Prop2" control="text" />
  <property name="Prop3" caption="Prop3" control="text" />
</propertygroup>

The property group has a special attribute, display. In this case, display is set to caption, which means all child properties are displayed under the caption. If the display caption is omitted, display is set to hidden, which means that the property group is hidden.

The second example illustrates how to show or hide properties according to the value of another selected property.

As shown in the following figure, the visibility of the properties depends on the value of property Group Select.

 

This group is created with the following XML code, which creates dependencies between properties:

<propertygroup name="Group2" caption="Another group" display="caption">
  <propertygroup name="Group3" caption="Group Select" display="property" control="select" 
default="Option 1">
    <attributes options="Option 1,Option 2,Option 3" />
    <property name="Prop1" caption="Prop For Option 1" visibleon="Option 1" control="text" />
    <property name="Prop2" caption="Prop For Option 1 and Option 2" 
     visibleon="Option 1|Option 2" control="text" />
    <property name="Prop3" caption="Prop For Option 3" visibleon="Option 3" control="text" />
  </propertygroup>
</propertygroup>

In this case, the attribute display is set to property. The PropertyGroup named Group3 defines a standard ACT property that provides additional capabilities for all child properties.

Each child property can specify an attribute visibleon, which can take a value or a set of values. If the current value of the parent property fits with the attribute visibleon, the property is displayed. Otherwise, the property is hidden.

The following example demonstrates how to create properties that open a worksheet each time the user needs access to the content of the properties. The type PropertyTable is used for such an application. This property type is of particular interest as it allows you to create a worksheet that exposes a set of properties for your customization.

To facilitate the development, ACT already provides some predefined worksheets. Two different types of worksheets are currently available:

  • Time-dependent

  • Non-fixed row dimension

Time-dependent Worksheets

In a time-dependent worksheet, the row number is initialized with the number of steps defined in the object AnalysisSettings. If the user of the extension adds or removes time steps in the object AnalysisSettings, the worksheet is automatically updated. Consequently, this type of worksheet represents an efficient way to manage time-dependent data within an extension.

 

This worksheet is created with the following XML code:

<propertytable name="TimeDep" caption="TimeDependent" display="worksheet" control="applycancel"
    class="Worksheet.TimeFreqTabularData.TFTabularData">
  <property name="Step" caption="Step" control="integer" readonly="true" />
  <property name="Time" caption="Time" control="float" readonly="true" />
  <property name="Temperature" caption="Temperature" unit="Temperature" control="float"></property>
  <property name="Pressure" caption="Pressure" unit="Pressure" control="float"></property>
</propertytable>

In this example, the attribute display is set to worksheet. In addition, the attribute class is used to specify the name of the IronPython class that manages the worksheet. For this application, the class TFTabularData is used. This class is defined in the script TimeFreqTabularData.py, which is located in the folder libraries/Mechanical/Worksheet that is part of the standard ACT installation.

The properties Step and Time integrate a specific treatment, as they are automatically populated with the information specified in the object AnalysisSettings. These two properties are optional.

Non-fixed Row Dimension Worksheets

In a non-fixed row dimension worksheet, the array is empty by default. You can add a new line by clicking the top left button.

 

This worksheet is created with the following XML code:

<propertytable name="Worksheet" caption="Non-Fixed row count" display="worksheet" control="applycancel"
    class="Worksheet.PropertyGroupEditor.PGEditor">
  <propertygroup name="TempOrPres" caption="TempOrPres" display="property" control="select" 
   default="Temperature">
    <attributes options="Temperature,Pressure" />
    <property name="Temperature" caption="Temperature" unit="Temperature" control="float"  
     visibleon="Temperature"></property>
    <property name="Pressure" caption="Pressure" unit="Pressure" control="float" 
     visibleon="Pressure"></property>
  </propertygroup>

  <property name="Scoping" caption="Scoping" control="scoping">
    <attributes selection_filter="face|edge" />
  </property>
  <property name="FileName" caption="FileName" control="fileopen">
    <attributes filters="Command files (*.bat)|*.bat|All files (*.*)|*.*" />
  </property>
</propertytable>

In this example, the class PGEditor is used. The class PGEditor is defined in the script PropertyGroupEditor.py, which is available in the folder /libraries/Mechanical/Worksheet.

You can access the content of the worksheet in the same manner as you do any other standard ACT property.

Using Templates to Create Property Groups

A template represents a generic method for defining a group of properties with the associated callback code. You can create a template to provide services that can be integrated into any extension. For example, you can build a template to generate a property that displays all the available coordinate systems for the current model. Advanced users find templates to be beneficial. You can enrich the templates currently integrated in ACT to customize the environment in a very efficient way.

In your ANSYS installation directory, controltemplates.xml for Mechanical is located here: ...\Addins\ACT\templates\Mechanical. The content of this file includes several templates, each of which is assigned a name. The following template is named coordinatesystem_selection.

<!-- Coordinate System Selection -->
<controltemplate name="coordinatesystem_selection" version="2">
    <property name="selectCoordinateSystem" control="select" 
class="templates.select.SelectCoordinateSystem">
</property>
</controltemplate>

The class SelectCoordinateSystem associated with this template is defined in the script select.py, located in ...\Addins\ACT\libraries\Mechanical\templates. A template has to be made of one single property. If several properties need to be defined, they must be integrated in a group. In the same folder, the script scoping.py supplies a template definition with different properties.

To link this template to a property, you fill the attribute control for the property with the name of the template.


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