DS WhitePapers Enterprise Knowledge Language Overview and Usage V1.0
DS WhitePapers Enterprise Knowledge Language Overview and Usage V1.0
Executive Summary
This document provides an overview of main concepts about the EKL, EKL
Capabilities, various functions and tools that are required to work with EKL, and
troubleshooting EKL Code. The objective is to help users get a better
understanding about the EKL.
This document also provides some sample examples about using various types of
EKL functions that will help the users to get started with EKL.
The target audience for this Best Practices document is Designers and
Administrators who are looking for information about Enterprise Knowledge
Language (EKL).
2
Best Practices
Table of contents
1. Introduction .................................................................................................................... 5
1.1. EKL Capabilities ......................................................................................................... 5
2. About EKL...................................................................................................................... 6
2.1. Understanding the Structure of EKL ........................................................................... 6
2.2. Object Types Hierarchy .............................................................................................. 8
2.3. Understanding EKL Terms ......................................................................................... 9
3. Defining Syntax in EKL ................................................................................................ 11
4. About EKL Editors........................................................................................................ 15
4.1. EKL Editor Interface ................................................................................................. 15
4.2. Knowledge Editor Toolbar ........................................................................................ 16
4.3. Language Browser ................................................................................................... 17
5. How to create an Action ............................................................................................... 19
3
Best Practices
4
Best Practices
1. Introduction
Knowledgeware solutions deliver a set of tools that help users to define, reuse, and share their
know-how throughout the extended enterprise. Knowledgeware is also tailored to support
customer business processes, enabling the customization of Product Lifecycle Management
(PLM) behaviors and applications through the Business Rules.
EKL is a DS, portable, object oriented, interpreted, Automation language that directly
manipulates the V6 objects:
UI creation (like VBA Forms) is possible using Know-how Apps User Experience app. This
app is available with a Design Apps Developer role (KAC).
With the new “web dialog” dialog box which uses web in win, the user can now build a UI
using html/js. This allows the user to have an interactive panel based on individual
requirement.
LIMITATIONS:
EKL works only with in-session data. When used in the context of Business Rules,
5
Best Practices
interaction with files like Excel & XML stored in the file system is not possible. However, if
you store the files as Resources, you can use such files in the Business Rules.
It is also not possible to call a VBA macro from an EKL feature but, you can call the Visual
Basic Actions.
2. About EKL
1. Types: A hierarchy of types (one type inherits only from one type)
2. Attributes: Each type has a list of attributes:
Simple (Boolean, string, real, integer, and so on..)
Reference to other objects
List (of values or reference objects)
6
Best Practices
EKL is defined in four layers from the very simple Mathematical language (M-EKL) to the
most complete Advanced language (A-EKL).
It is used in the following Knowledge artifacts that are related to the update process
through their parameters:
o Formulas
o Design tables functions
o Rules and checks provided in the Engineering Rules Capture app.
o Constraints satisfaction feature provided in Design Optimization.
7
Best Practices
It contains the applicative packages available in EKL. You can also use X-EKL to add
functions to the EKL language.
8
Best Practices
Object Type
o A V6 object type describes classification of all the
V6 objects depending on the characteristics and
behaviour of the object. A V6 object type always
inherits types from another object type except the
“Feature” Type.
Value Type
o The system provides different types of values
such as Integer, Real, Boolean, String, and all the
magnitudes (LENGTH, VISCOSITY, etc…). The
mix of value and object types provides a coherent
typing environment.
Feature (Core types & functions)
o All applicative types are inheriting from a basic
object type called “Feature” which means that
Feature is the basic type for all objects in V6.
9
Best Practices
In most usages of EKL, rules are created in the context of a particular model. This
model usually contains parameters (values that can be read or written), variables that
reference isolated geometries, or objects (that can be used as input)
User can select variables and objects directly in the Engineering Rules Capture app to
use inside the rules and can be passed as arguments of functions, methods, and
operators.
10
Best Practices
Variable declaration
o User can declare variables anywhere in the code and the scope of variable
depends on where they are declared.
Let NameoftheVariable(Type)
Where “Let ” is the keyword and the statement of the variable definition.
“NameoftheVariable” is the variable name and “(Type)” is the object’s internal
o You can use the Set keyword for type casting the variable. Set keyword performs
the assignment without checking the type. The result is NULL for a non-supported
type.
There are two ways to provide strings: use double quotes (“ “) as delimiters, or
single quote (‘ ‘) as delimiters. You can have strings within strings by combining
both.
Operators
These will allow you to manipulate and compare variables and other inputs, used
throughout the code
o +, -, *, /, =, ** Arithmetic operators
o ==, <, >, <=, =>, <> Comparison operators
o like, unlike Allows to test if an object belongs to a certain type
o And, Or Logical Operators
Loops
EKL provides two types of loops:
o The first type of loop allows to iterate on an integer variable until a criterion is
reached. It uses the ‘for’ and ‘while’ keywords. There is a default increment but it
is not used if the loop code explicitly modifies the loop variable.
11
Best Practices
o The other loops on all objects of a type within a collection. It uses the ‘for’ and
‘inside’ keywords.
The following script will return an item in the list closest to the iNbr value
where iList is a list containing Integers.
Note:
With this release, initialization of the increment variable within the loop
definition is now supported:
For i = 1 while
The variable is incremented automatically (+1) but can be overloaded.
In case the user does not want to make the increment then overlaoding is not
supported and may raise a problem in some cases.
Break statement: is used to exit a loop from any point within its body. When
the script is interrupted, the script evaluation goes directly to the instruction
located directly after the loop.
Let i,result (Integer)
result = 0
12
Best Practices
i = 1
for i while i < lines.Size()
{
result = length(lines[i])
if result > 100mm
{
break
}
}
The above script computes the total length of several lines and stops computing
once the total length is greater to 100mm.
Continue statement: after calling continue, the script goes directly to the first
instruction of the loop to start the next iteration.
Let i (Integer)
Let localResult(Real)
Let resultsList(List)
i = 1
continue
}
Else
{
resultsList.Append(localResult)
}
}
}
13
Best Practices
If …. else if … else
Method
14
Best Practices
Attributes
o Attributes represent all the information contained in a given Type (Name, Color,
and so on.). The syntax for access attributes of a given Type can be:
Constants
o EKL recognizes some universally used constants like:
PI, E: mathematical numerical constants
PHI: golden ratio
true, false: Boolean
NULL: to test if a non-literal variable is set or unset
1. Under Argument list (Action feature only), the user can define all the required
arguments and their Types. These Arguments are used in the Action code.
Note: You can also create Actions with no arguments. When running the action, a
smart selection mechanism takes place to provide the right object depending on the
expected type (a node in a product structure tree may represent an occurrence, an
instance or a reference.)
15
Best Practices
1. Preferences: to set some editor preferences like syntax errors, text formatting,
snapshots, colors, and so on from the Expression Editor Preferences menu.
2. Line: Shows the cursor position
3. Find and replace: This function enables users to find & replace text
4. Language Browser: see section 4.3 for details.
5. Syntax errors: If the user has not activated the syntax error option from the
Expression Editor Preferences menu, then the Syntax errors option from the
toolbar allows to check the syntax errors. And, the line containing the errors is
highlighted.
6. URLs and Comment: allows user to associate a URL or comment to any Action.
7. Text field eraser: cleans up all the content in the text field (code field).
Note: before selecting this option, take a backup of the code.
8. Undo/Redo: allows to undo or redo the last operation.
16
Best Practices
1. Type: represents the object’s PLM type the user is working on.
2. User can chose a Type from the drop down list shown below or select it from the
specification tree.
3. Supported/Inherited Types List: shows the inheritance structure.
4. Attributes: shows all attributes of the selected Type and the inherited types.
5. Functions Using Type: lists all functions using Similar Type/Inherited Type as one
of its argument.
6. Search: Allows to search functions that contain the search string.
17
Best Practices
18
Best Practices
Follow the sequence of numbers tags on the images below to perform the steps for creating
an Action:
19
Best Practices
To understand this process, you can also follow the sequence of number tags on the
20
Best Practices
21
Best Practices
Locally using a Resource Table: Follow the number tags on the following images to
understand the process for creating a local knowledge resource.
22
Best Practices
Popup Message : The script stops executing whenever it encounters a popup message.
let i = 1
Message("Hello World")
PopupMessage("i = #", i)
In the above script, Popup Messages appear at the time of script execution and the
Message appears at the end of the execution.
23
Best Practices
To avoid tooltip overlap, the messages are stored within a defined timeframe and
displayed together when the application idles. The notifications are stacked until the
notifications stack reaches 40 elements.
Notify is called using “|” as first character, which indicates that you want to start a
new notification stack.
When the application idles, the different stacks are displayed as tooltips. Each tooltip
appears for a certain time which is computed using the size of the message with a
maximum of 60 seconds.
let i = 1
Notify("Hello World")
for i while i < 3
Notify("i = #", i)
Let oPrevPLMRef(PLMCoreReference)
Let oNextPLMRef(PLMCoreReference)
Let oPrevType(Type)
Let oNextType(Type)
Let strPrevType(String)
Let strNextType(String)
oPrevType = oPrevPLMRef.ModelerType
strPrevType = oPrevType.Name
oNextType = oNextPLMRef.ModelerType
24
Best Practices
strNextType = oNextType.Name
Report("Error", "Both the Predecessor & Successor should of Operation Type to make the
relationship", "Please check the Predecessor & Successor Objects")
A library can contain more than one function. Each function has a signature (its parameters)
and a body.
A reusable function can include other functions from the same or other libraries.
In the following example, follow the number tags on the images to understand the process
for creating a Know-how library and how to use this library.
25
Best Practices
26
Best Practices
27
Best Practices
28
Best Practices
29
Best Practices
• Trace and analyze the execution of Knowledge applications (exit status, execution
times, I/O values, and for advanced users, stack traces, memory references and
memory footprints).
• Check attributes and parameters values as logged at execution.
• Trace the evolution of a given attribute throughout the entire execution, based on a
reference or on a name.
• Identify and Interact with logged entities in session.
1. Click the Knowledge Monitor Debug Command in the secondary area of the Tools
section before activating the entity to be traced.
2. Configuration Knowledge Monitor dialog box lists the available categories and their
activation flags:
30
Best Practices
Enabled: Indicates that the tracing is activated for the execution units belonging
to this category. In some cases though the user enables EKL expressions as
shown below, some expressions might still be hidden.
Hidden: Indicates that tracing stops for the entire branch under the unit when
execution hits a hidden category. Tracing reactivates once an enabled unit is hit.
3. The Knowledge Monitor toolbar appears as shown in image 3 below. You can:
Stop the Execution Traces (a)
Open Knowledge Monitor (b)
Add an object to the debug context (c )
1. Time Line: shows the complete trace at debug. Execution units are displayed in
a tree-like structure under a root node which is a virtual node independent from the
execution units.
2. Unit Profile Area: Double-clicking a node in the timeline opens the Unit Profile Area.
The unit profile provides information regarding:
Attributes that may be an input or output.
Message containing additional information about the execution
31
Best Practices
Disable Errors: This function is used to deactivate all the script lines containing the
errors. Errors that occur in an EKL script after you called DisableErrors are stored in a
list.
Enable Errors: This function is used to re-activate errors and retrieve the errors that
occurred after you called DisableErrors. It returns a list containing EvaluationError
objects corresponding to the errors raised by DisableErrors.
let resourceToFind(Feature)
let resourceName(String)
let listOfErrors(List)
32
Best Practices
DisableErrors()
resourceToFind = AccessResource(resourceName, "Feature")
listOfErrors = EnableErrors()
if resourceToFind == NULL
{
Message("#", listOfErrors.Size())
}
33
Best Practices
Procedure: search for all product references that have the string “Crankshaft” in their
Title attribute.
Let rootProduct(VPMReference)
Let strSearchStr(String)
Let strName(String)
34
Best Practices
When working on variables of type Occurrence, user must use the Occurrence
types and their attributes.
In the following example, the requirement is to find out the number of occurrences of
the 3D Part “Part_1 (sprd00567542)”.
35
Best Practices
Let I(list)
Let ref(VPMReference)
Let context(VPMReference)
The following script gives an Occurrence Object for a given Reference Object:
Let childrenList(List)
Let rootProduct(VPMReference)
36
Best Practices
Let productRef(VPMReference)
Let productOcc(ProductOccurrence)
Let occList(List)
Let strSearchStr(String)
Let strName(String)
rootProduct = oRootOccurrence.Reference
strName = "Part00007050"
strSearchStr= "x.V_Name ==" + " \"" + strName + "\""
childrenList = rootProduct->Query(“VPMReference", strSearchStr)
If childrenList.Size() > 0
{
Set productRef= childrenList->GetItem(1)
occList = productRef->ListOccurrences(rootProduct)
If occList.Size() > 0
{
productOcc= occList->GetItem(1)
Message("Occurrence Name = ", productOccOcc.Name)
}
Here,
ListInstances finds all the instances of the reference on which the method is called in
the context ref. The output is in the form of List.
In the following example, the requirement is to find out the number of instances of the
3D Part “Part_1 (sprd00567542)”.
Let I(list)
Let ref(VPMReference)
Let context(VPMReference)
37
Best Practices
Here, .ModelerType.Name gives the name of the object type that is created.
Create a Reference object with a parent. The result will be directly an Instance
object.
38
Best Practices
Let createdNewInst(VPMInstance)
Let parentRef(VPMReference)
Set parentRef = parentOcc.Reference
Set createdNewInst= new(“VPMReference", “MyNewInst", parentRef)
Message("Created object type is: #",createdNewInst.ModelerType.Name)
root.UpdateListOccurrences()
let l (List)
l = inst.Reference.ListOccurrences(root)
if (l.Size() <> 2)
Report("Error", "UpdateListOccurrences function failed",””)
It is very simple to retrieve the position matrix. But, you will get only the position
matrix of an instance in the context of its father. Refer to the following script:
39
Best Practices
// To be able to retrieve the position matrix in root context we must retrieve the occurrence of
the ref
root=GetEditorRoots("VPMReference").GetItem(1)
ref=inst.Reference
lstocc=ref->ListOccurrences(root)
occ=lstocc.GetItem(1)
40
Best Practices
indx = 1
For indx while indx < noOfRows
{
strColorName = oXLSheet.CellAsString(indx, 1)
rValue = oXLSheet.CellAsReal(indx, 2)
gValue = oXLSheet.CellAsReal(indx, 3)
bValue = oXLSheet.CellAsReal(indx, 4)
41
Best Practices
Note:
When reading Excel or CSV files, consider making Row 1 as the header row with
non blank values in the columns.
If any of the column in the first row is empty, EKL considers all the rows of the
column as empty.
CreateSheet is used for reading and writing into Excel. Its argument can be a
disk file path, a Data Setup path, or a logical name of the local Resource Table.
Note:
42
Best Practices
This syntax works only for disk files (not for database documents).
If intWBSCnt > 0
{
/* Using the result get each of the WBS Node's Text */
For xmlWBSNode inside listOfWBSNodes
{
xmlWBSNodeName = xmlWBSNode->Access("Name", "XMLNode")
oTextNode = xmlWBSNodeName.Children->GetItem(1)
strWBSName= oTextNode.Text
}
}
43
Best Practices
44
Best Practices
Set oXLSheet=CreateSheet("KnowledgeResources|Layers_code")
45
Best Practices
set mysolidfeaturesList=mybody.Children
for mysolidfeature inside mysolidfeaturesList
{
mylayer=mysolidfeature.Layer
indx=oXLSheet.LocateInColumn(1,mylayer)
R = oXLSheet.CellAsReal(indx, 3)
G = oXLSheet.CellAsReal(indx, 4)
B = oXLSheet.CellAsReal(indx, 5)
mysolidfeature.Color = ToString(R) + "," + ToString(G) + "," + ToString(B)
}
}
set myfeaturesList=mygeomset.Children
for myfeature inside myfeaturesList
{
mylayer=myfeature.Layer
indx=oXLSheet.LocateInColumn(1,mylayer)
R = oXLSheet.CellAsReal(indx, 3)
G = oXLSheet.CellAsReal(indx, 4)
B = oXLSheet.CellAsReal(indx, 5)
myfeature.Color = ToString(R) + "," + ToString(G) + "," + ToString(B)
}
}
46
Best Practices
Getting Started allows a user with no experience in EKL to be able to do basic scripts more
easily.
47
Best Practices
Note: Clicking once on the Getting Started icon opens a new Getting Started dialog box.
Clicking on this icon while the Getting Started dialog box is already open will close the existing
Getting Started dialog box.
The Getting Started contains a Table of content that lists different topics. The user can visit
any of these topics to get information on any particular subject. Samples are available for each
topic as shown in the image below. The user can come back to the Table of content by clicking
on the “Table of content” button.
48
Best Practices
49
Best Practices
13. References
3D Modeling > Multi Discipline Automated Engineering > Know-how Apps
Authoring Suite > Know-how Apps Logic > Creating a Library
3D Modeling > Multi Discipline Automated Engineering > 3D Templates Capture
> Reference Information > Design Table Functions
3D Modeling > Multi Discipline Automated Engineering > Know-how Apps
Authoring Suite > Know-how Apps Components > Working With Configured
Resources
50
Best Practices
51