View Update Rule Sample

A typical example of a view update rule script is as below:

Sample Enterprise Knowledge Language (EKL) Script

 // This action is checking if a Piping part is part
            // of a specific product
            //
            Let currentInstance (PLMCoreInstance)
            Let Father (PLMCoreReference)
            Let PipPartOcc(Piping_Pipe_Occurrence)

            // Let's  initialize Result to False to avoid issues
            Result = False

            // We try to get the Input as a Piping Part Occurrence
            set PipPartOcc = Input

            // If PipPartOcc is NULL, it means that Input is not a Piping Part Occurrence
            Result = (PipPartOcc <> NULL)

            // We have a Piping Part Occurrence
            if (Result)
            {
                // Let's retrieve the instance from the occurrence
                set currentInstance = PipPartOcc.Instance
                // if we retrieved the instance then try to get the father
                if (currentInstance <> NULL)
                {
                    set Father = currentInstance.Owner

                    // if the father product is retrieved
                    if (Father <> NULL)
                    {
                        // If the product title is "Fuel Oil Piping" then Result is true
                        // and the action for the view update rule will be executed
                        Result = (Father.V_Name == "Fuel Oil Piping")
                    }
                }
            }
 

Details of the code as follows:

  • The Input is processed, in this case tested if it is a PipingPart Occurrence.
  • If it is a PipingPart Occurrence, the Instance (currentInstance) is retrieved from the Occurrence, and the Owner (=Product Reference) is read from the instance.
  • The Title (=V_Name Knwoldege Attribute of PLMEntity) attribute of the product is read. And tested to have a specific value. If the Title matches the name tested for, a TRUE is returned, meaning the rule should be executed for this particular component.
  • All piping parts occurrences that are a direct child (=instance) of the product reference with Title: "Fuel Oil Piping" will be processed by this view update rule.

The actual view update rule performing as Action (applying graphical properties, part visibility in the view, etc.) is not specified in the script. It is defined in the View Update Rule dialog box.

You can define the Action in the script.