![](../icons_C2/common/ascenari.gif) |
Save the Required Data into the New
Directories Structure
-
Save the provided data in the appropriate directories:
![](images/pktarm1NLS.gif) |
- Save
PktBoxUDF.CATPart in the
CATKnowledgePath\knowledge\knowledgeResources
directory.
- Save
PktARMcatalog2.catalog in the
CATKnowledgePath\knowledge\knowledgeResourcesCatalogs
directory.
- Save
PktBox.CATGScript in the
knowledgeTypesCustom
directory referenced in the Reference Directory For Types.
|
-
Open the
PktQuantifierUDF.CATPart file.
Create the NbInstances Parameter
This parameter will enable you to determine the number of
User Features you want to instantiate
-
Click the Formula icon ( ).
The Formula editor opens.
-
In the New parameter of type combo box, select
Integer and click New parameter of type.
-
In the Edit name or value of the current parameter
field, double-click Integer.1 and enter NbInstances. Click OK.
The NbInstances parameter is created.
Create the Knowledge Pattern
This feature will enable you to instantiate the User
Features
-
From the Start>Knowledgeware menu, select the
Product Knowledge Template workbench.
-
Click the Create a Knowledge Pattern icon ( ).
The Knowledge Pattern Editor opens.
-
Enter the following code in the editor or copy/paste the
code contained in this
file:
let udf (PktBox)
1
let prev (PktBox) 1
let p (Plane) 1
let i (Integer) 1
i = 1
For i while i <= NbInstances 2
{
udf =
CreateOrModifyTemplate("PktARMcatalog2|BoxUDF", PartBody, Boxes, i)
if i == 1
udf.BoxInputPlane = FirstBoxPlane
3
else
{
prev = Boxes.GetItem(i - 1)
udf.BoxInputPlane = prev.NextBoxInputPlane
udf.PreviousBoxLength = prev.L
}
udf.SketchPlane = SketchPlane
EndModifyTemplate(udf)
udf.Name = "Box" + ToString(i) 4
i = i +1
}
|
![](../icons_C2/common/ainfo_custo.gif) |
In the script above, you first
declare the local variables (1),
2 corresponding to the type associated to the User Feature (in the
.CATGScript file), then a plane and an integer. Then you perform a
loop based on the number of instances set by the NbInstances
parameter (2). The
loop instantiates the User Features contained in the
PktARMcatalog2 catalog via the CreateOrModifyTemplate
function into the PartBody.
When instantiating the first User Feature, i=1, the input of the
User Feature is FirstBoxPlane (3).
For the other instantiations, the input of the User Feature
is the plane of the last instantiated User Feature. The length of
the instantiated User Feature corresponds to the exposed parameter
(L) of the last User Feature instantiated. At the end of the
instantiation process, a name is assigned to the instantiated User
Feature. This name is based on the concatenation of "Box" and the
number associated to the User Feature. (4). |
-
Click Add. List.1 = 0 elements is displayed in
the Knowledge Pattern Lists field. This list will list the number of
instantiated User Features.
-
Click it and replace it with Boxes in the Name
field.
-
In the Mode combo box, select Automatic
execution (before root update). This way, when you change the
number of desired instantiated User Features, the script will be launched
automatically.
-
In the specification tree, click the NbInstances
parameter. Use the spin box to indicate the number of instances you want
to instantiate (5 in this scenario.)
-
Click Execute now. The 5 boxes are
instantiated. Click OK to close the Knowledge Pattern window.
-
Double-click twice the parameter in the specification
tree. The Edit parameter dialog box displays.
-
Use the spin box to set the number of instances to 3 and
click OK. 2 instances are removed. Click
here to open the Part containing the Knowledge Pattern.
|