Context Object Parameters
In addition to the fact object, context attributes are available in the scripting rule. Some parameter availability are based on
OperationId and
OperationDetail attribute combination. See the matrix below.
Parameter Names | Types | Read/Write | Comments |
---|
OperationId | string | Read | Parameter used to identify the context of initialization. Following values are
not exhaustive.
- "New” for Component creation.
- "Cloning" for Component duplication.
- "Implicit" for Component creation by factory APIs with no specific
context.
- "ImportAsNew" for data import creating new Components.
- "ImportAsRef" for object re-identification at import.
- "Default" for any else case.
|
OperationDetail | String | Read | Parameter to be used combined with OperationId parameter. Details the context of the OperationId.
Following values are not exhaustive.
- "NoOperationDetail"
- "Create"
- "CopyPaste"
- "ConfiguredSplit"
- "ReplaceReference"
- "CloneDistantData" for "Duplicate As Alternative" command.
- "AssemblySymmetry"
|
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.
|
CoupledRef | PLMEntity | Read | When creating a couple "PLM Part Reference/Representation Reference" in one shot, this parameter provides the PLM Proxy object of the aggregating Part Reference. Based on this object, the attributes values may be parameterized. |
AggregatingReference | PLMEntity | Read | When creating a PLM Instance, this parameter provides a PLM Proxy object of the PLM Reference entity (i.e. OwnedBy) that will aggregate the PLM instance. Based on this object, the attributes values may be parameterized. |
Reference | PLMEntity | Read | When creating a PLM Instance, this parameter provides a PLM Proxy object of the PLM Reference entity (i.e. (InstanceOf) of the this PLM instance. Based on this object, the attributes values may be parameterized. |
Policy | String | Read | Policy name. |
Summary of the available context for each OperationId:
- Type of the fact object
- OperationDetail
- Context attribut parameters
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 stand alone Representation Reference based on a unique number computed by an external function of a user knowledge package.
- 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)
{
...
Assembly Symmetry sample
The following sample illustrates how to customize the name of new symmetric references.
Let OperationDetail(string)
Let CopyFrom(PLMProductDS)
Let CopyFromId(string)
Let Prefix(String)
OperationDetail=Parameters->GetAttributeString("OperationDetail")
If(OperationDetail=="AssemblySymmetry")
{
/*Do specific treatments*/
Prefix=Parameters->GetAttributeString("IdCloningString")
CopyFrom=Parameters->GetAttributeObject("CopyFrom")
CopyFromId = CopyFrom->GetAttributeString("PLM_ExternalID")
ThisObject.PLM_ExternalID = Prefix + CopyFromId
}