Category and LabelThe OTScript feature can be associated with a category. You can specify a label for a feature. Note:
If no category is defined, Extensions is used as the default
category.
You can also declare the category in the label. METHOD ... CATEGORY "Customer" LABEL "Quantity"; // the category is Customer and label is Quantity METHOD ... LABEL "Quantity"; // the category is Extensions and label is Quantity METHOD ... LABEL "Customer,Quantity"; // the category is Customer and label is Quantity Class PatternThe following pattern enables you to define a class: Syntax
CLASS <class_name> -doc : <type>; Attribute PatternThe following pattern enables you to define an attribute: Syntax ATTRIBUTE <class_name>.<attribute_name> -doc : <type> CATEGORY <category> LABEL <label>; Method PatternYou can provide a help text for methods: The following pattern enables you to define a method: Syntax METHOD <type_name>.<method_name>() -doc : {
...
<code>
...
} LABEL "<category>,<label>"
HELPTEXT "<tooltip>";
Description
Example1PACKAGE Customer;
CLASS BOMElement -doc : Entity_;
ATTRIBUTE BOMElement.quantity -doc : Integer CATEGORY "Customer" LABEL "Quantity";
ATTRIBUTE BOMElement.reference -doc : PLM.VPMReference CATEGORY "Customer" LABEL "Product reference";
METHOD BOMElement.initialize(ref : PLM.VPMReference) : {
quantity := 0;
reference := ref;
THIS
};
METHOD BOMElement.add() : { quantity := quantity + 1 };
CLASS BOM -doc : Entity_;
ATTRIBUTE BOM.elements -doc : BOMElement CATEGORY "Customer" LABEL "BOM Elements";
METHOD BOM.addProductReference(ref : PLM.VPMReference) -doc : {
TMP element := dictionary.at(ref.id)[EACH ISA BOMElement];
$NO(element) IF TRUE: {
element := NEW(BOMElement).initialize(ref);
dictionary.atPut(ref.id, element);
};
element.add() // It return the current quantity
} CATEGORY "Customer" LABEL "Add product reference"
HELPTEXT "Provide a Physical Product reference as argument to increase quantity";
Example2This example shows a method, which counts the number of requirements that are refined.Satisfy the following prerequisites:
Insert the following code in the OTScript tab of your template. This code creates a method named Number of refined requirements, which is added to the Customer category: PACKAGE PLM;
METHOD `Requirement Group`.getDerivedRequirementsCount() -doc : {
TMP reqSpecs := `rel_Requirement Group Content`.`to_Requirement Specification`;
$CNT(reqSpecs.getAllRequirements()[$SOME(`rel_Derived Requirement`)])
} CATEGORY "Customer" LABEL "Number of refined requirements"
HELPTEXT "Get the number of requirements that are refined by other requirements";
| |||||||||||||||||||||||