CATRule
CATRule
https://help.3ds.com/2019x/english/dsdoc/EKLRefMap/kwa-m-EKL-Advanced-sb.htm?
contextscope=onpremise&id=20f9c85f6f1e433591ec6b8894083838
The following sample determines the attributes to add in the Spread Sheet editor.
/* -------------------------------------------------------------------------*/
/* Variables declaration */
/* -------------------------------------------------------------------------*/
/* ---- output ---- */
Let AttributesKeys(List)
Let AttributesValues(List)
Let AttributesTitles(List)
Let AttributesEditable(List)
/* Resource Rule */
let hOperationRef(PLMOperation)
let nbOfItems(Integer)
let ii(Integer)
let ListOfResources(List)
let ListOfResourceNames(List)
let nbOfResources(Integer)
Let hResourceOcc(ResourceOccurrence)
Let hResourceInst(VPMInstance)
Let hResourceWhere(ResourceOccurrence)
let ListOfResourceWho(List)
let Description(String)
let SplitDescription(String)
let lengthOfDescription(Integer)
let ListOfDescriptions(List)
let ContinueWhile(Integer)
let oIndex(Integer)
ListOfDescriptions.Append(SplitDescription)
}
}
}
}
}
/* Resource Rule */
/* Retrive working resources using PLM_ExternalID */
set nbOfItems = ListOfDescriptions.Size()
if(nbOfItems > 0)
{
/* Get working resource list and then appned PLM_ExternalID from it */
set ListOfResources = Parameters-
>GetAttributeObject("ListOfResourcesWho")
set nbOfResources = ListOfResources.Size()
set ii=1
for ii while ii<=nbOfResources
{
set hResourceOcc = ListOfResources.GetItem(ii)
if(hResourceOcc <> NULL)
{
set hResourceInst = hResourceOcc.Instance
if(hResourceInst <> NULL)
{
ListOfResourceNames.Append(hResourceInst.PLM_ExternalID)
}
}
}
/* Compare with PLM_ExternalID. If it is same, append to the list */
set ii=1
for ii while ii<=nbOfItems
{
set Description = ListOfDescriptions.GetItem(ii)
set oIndex = ListOfResourceNames.IndexOf(Description, 1)
if(oIndex > 0)
{
ListOfResourceWho.Append(ListOfResources.GetItem(oIndex))
}
}
if(ListOfResourceWho.Size() > 0)
{
Parameters->SetAttributeObject("ResourceWho",
ListOfResourceWho)
}
}
/* Retrieve Where resource from Who resource*/
if(ListOfResourceWho.Size() > 0)
{
set hResourceOcc = ListOfResourceWho.GetItem(1)
if(hResourceOcc <> NULL)
{
set hResourceWhere = hResourceOcc.Owner
if(hResourceWhere <> NULL)
{
Parameters->SetAttributeObject("ResourceWhere",
hResourceWhere)
}
}
}
The table below provides you with information related to the definition of the Opening ID.
Input Objects
Input objects must be of the following types:
ThisObject
Parameters corresponds to the context object.
Validation
Parameter
Type Read/Write Comments
Name
Read/
Parameter Names Types Comments
Write
WarningAttribute list Write Output parameter which contains the list of the
s of attribute identifiers which valuation leads to raise a
string user warning.
s
Parameter
Type Read/Write Comments
Name
ErrorAttributes list Write Output parameter which contains the list of the
of attribute identifiers which valuation leads to raise a
string user warning.
s
WarningMessages list Write Output parameter which contains the list of the NLS
of warning message corresponding to each
string WarningAttribute.
s
ErrorMessages list Write Output parameter which contains the list of the NLS
of error message corresponding to each ErrorAttribute.
string
s
Note: These lists are accessed in rules with GetAttributeObject API on the context. They must be
set on the context with SetAttributeObject at the end of the rule ( see sample ) unless they won't
be applied.
Sample
The following sample show how to:
Check that the description attribute does not contain the ‘%’ forbid character and raises a
warning if not checked.
Check that V_supplier is well valuated and raised an error if not checked.
Check that the description attribute is valuated. The resulting UI message will be the
following ones
<Scripts>
<Script OpeningID="PLMAttributesValuationCheck"
Type="MyPLMProduct"
ScriptName="MyProductAttrCheckScript" />
</Scripts>
This family references the script that contains the business logic implementation, which looks like
the following CATRule file:
Let Errorlist(List)
Let Warninglist(List)
Let ErrorMessagelist(List)
Let WarningMessagelist(List)
Let PublishedMessage(String)
Let Supplier(string)
Let Description(string)
Let MyDescription(string)
Let MyId(string)
Let InvalidChar(string)
Validation=true
Supplier = ""
if ((ThisObject.V_Supplier==true) and (ThisObject.V_SupplierName == Supplier))
{
Validation=false
ErrorMessagelist->Append("supplier not valid")
Errorlist->Append("V_SupplierName")
}
Description = ""
MyDescription = ThisObject.V_description
if (MyDescription == Description)
{
Validation=false
WarningMessagelist->Append("Description should be valuated")
Warninglist->Append("V_description")
}
InvalidChar = "%"
if (MyDescription<>NULL)
{
if (MyDescription.Search(InvalidChar) <> -1)
{
Validation=false
WarningMessagelist->Append("Character % is forbidden in description")
Warninglist->Append("V_description")
}
}
MyId = ThisObject.PLM_ExternalID
if (MyId.Search(InvalidChar) <> -1)
{
Validation=false
WarningMessagelist->Append("Character % is forbidden in PLM_ExternalID")
Warninglist->Append("PLM_ExternalID")
}
if (Validation == false)
{
Parameters->SetAttributeObject("ErrorMessages",ErrorMessagelist)
Parameters->SetAttributeObject("ErrorAttributes",Errorlist)
Parameters->SetAttributeObject("WarningAttributes",Warninglist)
Parameters->SetAttributeObject("WarningMessages",WarningMessagelist)
}
Attributes Initialization (PLMIdentificationInitialization)
PLMIdentificationInitialization lets you define and integrate the customer business
logic for PLM entity initialization.
Note: For more information about customization by business rules, see Installation and
Setup: Customize: Behavior: Data Setup: Customization by Business Rules.
Notes:
In an import context, the type you want to use must be retrieved using
the RetrieveNamingParametersWithSeparator function.
You must create a rule defining that the value of the attributes that
Functions.
General Information
Input Objects
Sample
General Information
This opening ID is called in the Content > New, Edit Properties and Sheet Editor dialogs each time
the user manually modify an attribute value. The Attribute Valuation Propagation Business Logic
has been called before applying the current propagation BL. The goal of the BL is to propagate
attributes valuation ( Attri=f(Attrj) ) and manages attribute visibility.
The table below provides you with information related to the definition of the Opening ID.
Input Objects
This opening ID can be associated with component class types below. This is the fact (i.e.
ThisObject) in the business rule.
ThisObject
Read/
Parameter Names Types Comments
Write
"NoOperationDetail"
"Create"
"CopyPaste"
"ConfiguredSplit"
"ReplaceReference"
IdString string Read Parameter that may be used for the naming of the
PLM entity (e.g. as prefix).
IdCloningString string Read Parameter that may be used for the naming of the
PLM entity (e.g. as prefix).
CopyFrom PLMEntity Read PLM Proxy object of the source PLM entity to clone.
Based on this object, the attributes values may be
parameterized.
parameterized.
OperationDetail
Note: Depending on the context, some parameters may be unset. Therefore, it is necessary to
check attribute validity before reading.
Sample
The following sample illustrates how to:
Initialize the naming of a Representation Reference from the naming of a couple Part
Reference (same PLM_ExternalID attribute prefixed by "3DRep of ")
Set the attributes on a cloned Representation Reference: the description of the cloned
object is set to : "This Representation is a copy of Original object PLM_ExternalID"
To achieve this particular business logic implementation you will associate a rule (e.g.
"MyRepIdentificationScript") with the couple <OpeningID, Type> in a CATRuleExit file:
<Scripts>
<Script OpeningID="PLMIdentificationInitialization"
Type="MyPLMRepresentation"
ScriptName="MyRepIdentificationScript" />
</Scripts>
Then you will create a business rule to define your business logic:
Let Operation(string)
Let CoupledRefId(string)
Let CoupledRef(PLMProductDS)
Let OriDesc(string)
Let CopyFrom(PLMProductDS)
Let CopyFromId(string)
Let CloningString(string)
Operation=Parameters->GetAttributeString("OperationId")
If(Operation=="New")
{
/* Management of coupling between Representation Reference Naming and Part
Reference naming */
if (ThisObject->HasAttribute("AggregatingReference") == true)
{
set AggregatingRef = ThisObject.AggregatingReference
if (AggregatingRef <> NULL)
{
CoupledRefId =
AggregatingRef.PLM_ExternalID
ThisObject.PLM_ExternalID =
Prefix+CoupledRefId
}
else
{
/* Default naming based on a
customized numbering */
Prefix = Parameters-
>GetAttributeString("IdString")
ThisObject.PLM_ExternalID = Prefix
+"Representation"
}
}
else
{
/* Default naming based on a customized numbering */
Prefix = Parameters->GetAttributeString("IdString")
ThisObject.PLM_ExternalID = Prefix +"Representation"
}
}
else if(Operation=="Cloning")
{
/* Case of cloning */
if (Parameters->HasAttribute("IdCloningString") == true)
{
CloningString = Parameters->GetAttributeString("IdCloningString")
}
if(CloningString=="")
{
CloningString = "Auto Renamed of "
}
/* retreive the attributes on the initial object */
set CopyFrom = Parameters->GetAttributeObject("CopyFrom")
CopyFromId = CopyFrom->GetAttributeString("PLM_ExternalID")
OriDesc = CopyFrom->GetAttributeString("V_description")
ThisObject.PLM_ExternalID = CloningString + CopyFromId
ThisObject.V_description = "This Representation is a copy of "+CopyFromId
Note: Before using an optional input parameter, you have to check its value. For example, to
check if the CopyFrom parameter is valuated or not, use the following code sequence:
...
set CopyFromRef = GetAttributeObject("CopyFrom")
if(CopyFromRef <> NULL)
{
...
The CATNls file is required to display the comments associated with the
charset="UTF-8"/>.
9. let vp(ValuePointer)
10. let li(List)
11.
12. /*Inserted to positioned two values Grey & Blue as authorized values for
the description attribute*/
14. li->Append("Grey")
15. li->Append("Blue")
16. vp = ThisObject->GetAttributeValuePointer("V_description")
vp.AuthorizedValues=li
17. Click OK twice.
The business rule is created and the authorized values are displayed when creating a
new object.
18. To translate the values displayed in the above dialog box, create a CATNls file.
As V_description attribute belongs to the PLMEntity type, we are going to create a file
which name is PLMAttrValuePLMEntity.CATNls. Enter the following code into the text
editor:
19. /* Translates Blue into Bleu and Grey into Gris for the attribute
V_description*/
V_description.Grey= "Gris";
21. Save your file in the runtime view in the following directory: intel_a\resource\
msgcatalog.
The translated values are now available when creating a new object.
Note: To translate the authorized values of a given attribute, you must define them in a
CATNls file corresponding to the type that defines this attribute. You can define these
values on the type subtypes, which enables you to define a particular translation for a
given subtype that will not be used for another subtype.
Link: https://help.3ds.com/2019x/english/dsdoc/PjrUserMap/pjr-t-NLSFileDeliver.htm?
contextscope=onpremise&id=588807409e8f4b88ba2a1bae94df48c4
Opening IDs
This section provides you with information about opening IDs.
The system is delivered with a set of pre-defined openings so that you integrate your specific
processes. The implementation of an opening is performed through rules. A rule is the
description of the behavior alteration in the Enterprise Knowledge Language (EKL). EKL is an
interpreted language that manipulates variables, constants, operators, attribute accessors,
functions and keywords through a strict grammar.
Customization Intent
The system triggers the business rule with a customization intent. There are three types of
intents:
Computation: Used to compute a result from the state of an object. Only the best possible
rule for the couple <object type, opening> is executed.
Execution: The object can be modified by the rule. Only the best possible rule for the
couple <object type, opening> is executed.
1. The administrator (or the business rule architect) creates one or several business rules
for the selected opening ID. The rule body must be compliant with the EKL syntax. It
manipulates the input object and the context object as variables. This rule will be a
dedicated object stored in database.
Note: For the same opening ID , several business rules can be created, according to the
different possible fact types and P&O projects to which the resource sets will be bound.
2. The administrator creates or edits an existing resource table containing the selected
opening ID and assigns the created business rules to the different couples <Opening ID>
| <Fact Type>.
3. When satisfied with the customization, the administrator deploys his customization on the
production server.
ThisObject
ThisObject is a variable that represents the object on which the rule is acting. The type of this
variable is determined when creating the business rule. In execution mode, attributes may be
modified by the rule whereas in validation or computation mode, attributes can only be read by
the rule.
Parameters
This is a variable of RuleContext type that represents the object that provides contextual
information about the opening.
Important:
Validation (optional)
If the rule is used by the opening as a validation, an additional Validation variable of Boolean
type is available in the rule. The rule writes its value to express the validation.
Examples
Example 1
Example 2
The message is valuated to explain the origin of the problem. If you want to provide NLS
messages, use the BuildMessageNLS function.
Debugging Variables
Methodology
An administrator writes rules and plugs them to the openings thus altering the behavior of the
system. This can be achieved as follows:
The administrator:
2. Writes a business rule that is compliant with the EKL syntax, manipulating the input object
and the context object as variables, and he or she saves it.
3. Plugs this business rule to the collaborative space using Data Setup: he can choose a
collaborative space to use for test purposes only.
4. Tests the behavior of his system that takes the rule customization into account. He or she
can have his own test collaborative space.
5. Deploys the customization on the server or on the clients to customize the system by
associating the business rules with collaborative spaces in production.
Debugging Variables
The administrator activates environment variables for debugging purposes:
CKE_CUSTO_TRACES=1: Variable used to have traces generated by the customization engine,
explaining the problems encountered: scripts not found, scripts not valid syntactically, scripts
failing at runtime for example. If set to 2, ThisObject and Parameters are dumped.
Note: If the Trace function is used in the script, the string passed to this function is traced too.
CKE_CUSTO_TRACES_RESTRICTION: Variable used to specify the opening ID to be traced and
possibly the Type of the objects to be traced. It is also possible to provide a list of couples
(OpeningID/Type of fact). To set the environment variables, separate the strings using a ';'.
The list of traces raised by the customization engine when the traces are activated is the
following:
Business Rules execution: <OpeningID>: At the beginning of the execution, indicates which
opening is triggered.
Business Rules validation: <OpeningID>: At the beginning of the validation exit, indicates
which opening is triggered.
Operation validated. Additional message added to the script: <Message>.
Operation not validated. Additional message added to the script: <Message>.
Business Rules computation: <OpeningID>: Indicates which opening is triggered.
Business Rules execution re-directed to script <ScriptName>
Business Rules execution failed because script <ScriptName> was not found in
the runtime environment: Indicates at the end of the script execution that no script was
associated with the opening ID.
Business Rules execution failed because the syntax of the script <ScriptName>
is invalid: <SyntaxErrorMessage>: Indicates that the syntax of the script is invalid and
shows the syntax error message.
Business Rules execution failed because script <ScriptName> execution produced
an evaluation error: <EvaluationErrorMessage>:: Indicates that the evaluation of the
script raised an error and shows the evaluation error message.
The context of the business rules is (name=<Name>, user=<UserID>,
security=<SecurityContext>.: Provides information about the parameters of the opening.
Business Rules testing opening: <OpeningID> succeeded: Traces the testing of the
opening.
Business Rules testing opening: <OpeningID> failed: Traces the testing of the
opening.
Trace raised: <Traces>: traces the message passed to the Trace function.
Message raised: <Message>: traces the message passed to the Message function.
Redirection file read : <Name of the .CATRuleExit file>.
Script file read : <ScriptName>.
Script file not found or readable : <ScriptName>.
Misplaced condition in redirection file <Name of the .CATRuleExit file>.
Invalid tag <an XML tag> in redirection file <Name of the .CATRuleExit file>.
Invalid attributes for tag <an XML tag> in redirection file <Name of
the .CATRuleExit file>.
Opening <OpeningID> for type <Type> to script <Name of the .CATRule file> with
condition <a condition> is eligible.
Opening <OpeningID> for type <Type> to script <ScriptName> with condition <a
condition> has been rejected.
Opening <OpeningID> with condition <a condition> has been selected because of
greater accuracy (= level of accuracy).