Creating the Extension for Geometry Creation

The file GeometryFeature.xml follows. DesignModeler requires PNG files for the images to display as toolbar buttons.

<extension version="1" name="GeometryFeature"> 
<script src="main.py" />
  <interface context="DesignModeler">
    <images>images</images>
    <toolbar name="ACTtoolbar" caption="ACTtoolbar">
      <entry name="MyFeature" icon="construction">
        <callbacks>
          <onclick>createMyFeature</onclick>
        </callbacks>
      </entry>
    </toolbar>
  </interface>
  <simdata context="DesignModeler">
    <geometry name="MyFeature" caption="MyFeature" icon="construction" version="1">
      <callbacks>
        <ongenerate>generateMyFeature</ongenerate>
        <onaftergenerate>afterGenerateMyFeature</onaftergenerate>
      </callbacks>
      <property name="Face" caption="Face" control="scoping">
        <attibutes selection_filter="face"/>
      </property> 
      <property name="Length" caption="Length" control="float" unit="Length" default="1.2 [m]"></property>
      <property name="Minimum Volume" caption="Minimum Volume" control="float" unit="Volume" >
<attributes readonlyaftergenerate="true" />
      </property>    
    </geometry>
  </simdata>
</extension>

The element <script> defines the path to the IronPython script main.py. The element <interface> has the attribute context set to DesignModeler. The element toolbar defines the custom toolbar for creating a geometry. The callback function createMyFeature creates the geometry and adds it to DesignModeler.

The element <simdata> defines the geometry. The attributes in the child element <geometry> provide the name, caption, icon, and version that apply to the geometry.

The child element <callbacks> has two callbacks: <ongenerate> and <onaftergenerate>.

  • The callback <ongenerate> specifies the function to invoke when the geometry is generated by the product. The product provides the geometry type (type IDesignModelerGeoFeature) as the callback argument.

    This callback must return a Boolean value to indicate whether the generation has been successful. It returns true if the generation succeeds and false if it fails.

  • The callback <onaftergenerate> specifies the function to invoke after the geometry is generated by the product. The product provides the geometry type (type IDesignModelerGeoFeature) as the callback argument.

To specify additional details about the geometry, you can include additional callbacks, such as <canadd>, <onadd>, <oninit>, and <onmigragte>.

In the callback definition, you define the properties to apply to the definition of the geometry. In this example, the properties Face and Length are applied. The Details View pane of DesignModeler displays these properties so that the necessary values to complete the geometry definition can be supplied. The next section describes how geometry properties are retrieved and modified.

The following figure shows that each defined property appears in the Details View pane with the corresponding names and types of interface control.

 

The two geometry properties, Face and Length, use different control types.

  • For the property Face, the attribute control is set to scoping. The attribute selection_filter is set to face. This specifies that the value for this property is one or more faces. The faces defined in the script main.py and used to generate the geometry.

  • For the property Length, the attribute control is set to float. It does not require the definition of one specific callback. The attribute unit is set to length, which introduces a physical quantity dependency. The attribute default specifies 1.2[m] as the default value. This default value is exposed in the Details View pane each time a new load is created.