Extends
The "Extends" object allows to import and use an object created in the Library into another object. It does not facilitate communication between objects, but instead places all elements of the imported object directly into the object that it is extending.
The imported object must be a Group type and it has mandatory parameter names that are defined in the code of the object. If these parameters are not defined, they will be given a default value, which is the value defined in the main project.
This means that an object can inherit the properties and behavior of another object, allowing you to reuse code and create more organized and modular designs.
The child object (the one that extends another object) can inherit all the properties and behavior of the parent object, and it can also add, modify or override certain properties and behavior as needed. This helps to promote code reusability, reduces duplication, and makes it easier to maintain and update your code.
Additionally, another use of “Extends” is to eliminate the repetitive lines of code in different objects such as the same enumeration groups or Role=”Input” parameters. This is achieved by calling the object which contains the common parameter/object sets in the first line of the project using “Extends”. This feature supports the extension of more than one object in the first line.
Example:
<O N="Extends_Object1" T="Project" Category="Core Objects">
<!-- created by ParamML Examples on 30.01.2023 -->
<O N="Support_Condition_Inputs" T="Group" Label="degree of freedom">
<P N="Tx" V="0" D="[Free=0/Fixed=1]Tx" Role="Input" Category="Support_Condition_Inputs" />
<P N="Ty" V="1" D="[Free=0/Fixed=1]Ty" Role="Input" Category="Support_Condition_Inputs" />
<P N="Tz" V="0" D="[Free=0/Fixed=1]Tz" Role="Input" Category="Support_Condition_Inputs" />
<P N="Rx" V="1" D="[Free=0/Fixed=1]Rx" Role="Input" Category="Support_Condition_Inputs" />
<P N="Ry" V="1" D="[Free=0/Fixed=1]Ry" Role="Input" Category="Support_Condition_Inputs" />
<P N="Rz" V="1" D="[Free=0/Fixed=1]Rz" Role="Input" Category="Support_Condition_Inputs" />
</O>
<O T="Document">
<O T="DocDesignCode" Obj="Support_Condition_Inputs" />
</O>
</O> |
We have an object that defines the "degrees of freedom" of the support components, and we require the parameters from this object in another component. By using the "Extends" object, we were able to access and utilize the required parameters. |
<O N="Extends_Object2" T="Project" TransAlignRule="Right" Category="Core Objects">
<!-- created by ParamML Examples on 30.01.2023 -->
<O N="Internal" T="Unit" Length="Inch" Force="Kip" Angle="Degrees" Temperature="Fahrenheit" Time="Sec" />
<O N="Geometry" T="Unit" Length="Feet" Force="Kip" Angle="Degrees" Temperature="Fahrenheit" Time="Sec" />
<O N="Support_Inputs" T="Group">
<P N="Support_Location" V="120" Role="Input" Category="Support_Inputs" />
<P N="Support_length" V="24" Role="Input" Category="Support_Inputs" />
<P N="Support_width" V="48" Role="Input" Category="Support_Inputs" />
<P N="Support_thickness" V="36" Role="Input" Category="Support_Inputs" />
</O>
<O N="E_O" T="Group" Extends="Extends_Object1" Override="1">
<P N="Tx" V="0" D="[Free=0/Fixed=1]Tx" />
<P N="Ty" V="1" D="[Free=0/Fixed=1]Ty" />
<P N="Tz" V="0" D="[Free=0/Fixed=1]Tz" />
<P N="Rx" V="1" D="[Free=0/Fixed=1]Rx" />
<P N="Ry" V="1" D="[Free=0/Fixed=1]Ry" />
<P N="Rz" V="1" D="[Free=0/Fixed=1]Rz" />
</O>
</O> |
When we use the "Extends" object, we have the option to modify any aspect of the object being extended. This is done by using the "Override" keyword. |
To view this example in the library, see (Extends_Object1 → OpenBrIM Platform , Extends_Object2 → OpenBrIM Platform)