Defining Rules Working on UDFs  

atarget.gif (1372 bytes) This task explains how to define expert rules working on User-Defined Features.
For more information about UDFs, see Product Knowledge Template User's Guide.
  • To perform this task, it is highly recommended to be familiar with the User-Defined Features concept and with the Part Design workbench. For more information about the UDF concept and Part Design, see Product Knowledge Template User's Guide and Part Design User's Guide
  • Go to the Tools>Options...>Parameters and Measure menu, click the Knowledge Environment tab. In the Reference Directory For Types, enter the path of the .CATGscript containing the type that is to be generated and click OK.
ascenari.gif (1364 bytes)
  1. From the Start>Mechanical Design menu, access the Part Design workbench.

  2. Click the Sketcher icon, the xy plane, and create a rectangular sketch.

  3. Create a parameter of Length type. 

    • Click the icon.

    • Select Length in the scrolling list to define the type of the parameter, click New parameter of type, change the name of the parameter (Distance_To_Axis in this scenario), and set its value to 0mm. Click OK.

  4. Create a constraint on the Distance_To_Axis parameter that will define the distance between the left vertical edge of the sketch and the VDirection-AbsoluteAxis.

    • Select the axis and the edge.

    • Click the Constraint icon () and click in the geometrical area to define the constraint.

  5. Double-click the digital value of the constraint, right-click the Value field, select Edit formula..., and enter PartBody\Sketch.1\Offset.5\Offset = Distance_To_Axis by selecting Distance_To_Axis in the specification tree or in the Member of All window. Click OK twice.

  6. Close the sketcher and create a pad by clicking the Pad icon ().

  7. Create the user feature.

    • Choose the Insert>KnowledgeTemplates>UserFeature command.

    • Select the Definition tab, rename the user feature (UDF1 in this scenario), and add the pad and the parameter by selecting them in the specification tree.

    • Publish the Distance_To_Axis parameter. To do so, select the Parameters tab, select the Distance_To_Axis parameter in the Available parameters column to publish the Distance-To-Axis parameter. 
      Check the Published Name check box, rename the parameter (Axis in this scenario).

    • Select the Type tab, and, in the Super Type field, click Auto. MechanicalFeature is displayed.
      In the Type1 field, enter UDF1 and click Generate.

  1. Click OK to close the Userfeature Definition window: a UDF is added to the KnowledgeTemplates node.

  2. Add a new body to the CATPart file. To do so, access the Part Design workbench and go to Insert>Body. Rename the inserted body (Result_Body in this scenario).

  3. Access the Knowledge Advisor workbench. 

  4. Click the Loop icon.

    The Loop function enables you to instantiate a UDF in its creation CATPart.

  5. Click the Context field and select Result_Body in the specification tree.

  6. Select UDF1 in the specification tree. UDF1 is displayed in the Name field.

  7. In the From field, enter 1 and enter 4 in the To field.

  8. In the Loop editor, enter the following script.

    UDF_$i$ isa UDF1 // UDF1 is the name assigned to the UDF
    {
    Axis = 120mm * $i$; //Name of the published parameter
    }

    In the script above, the UDF is instantiated by using the user type.

  9. Click OK: the UDFs are instantiated in the CATPart. 4 pads are displayed: the one you created and the 3 instantiated ones.

  1. Access the Knowledge Expert workbench. 

  2. Click the Expert Check icon (kwxWKChecks.gif (1236 bytes)), rename the check, select the KWE language, and click OK. The Check Editor opens.

  3. Enter the following script in the editor, then click Apply and OK.

    udf1:UDF1 // UserFeature1 is the instance you indicated Step 10
    Editor Message("#", udf1.Axis) /*Axis is the name of the published parameter*/
  4. Click the Solve icon (). A message box displays the distance to axis of each UDF.

The types generated when creating the UDF appear in the Object Browser (of the Expert Check Editor and of the Expert Rule Editor) in the package you selected in the Manage Type window.

aendtask.gif (1477 bytes)