How to Implement the Import Export Attributes Valuation Business Logic? |
Technical Article |
AbstractThis article details how you can implement the Import Export Attributes Valuation Business Logic based on the knowledge scripting technology. |
This business logic can be invoked in 2 different contexts:
This Business Logic is called:
This section describes the objects defining the PLM opening: its global information, its kind of input object, its context object parameters.
PLM Opening ID | PLMImportExportAttributesValuation |
---|---|
Customization Intent | Execution |
Execution Context | Client |
The Business Logic can be invoked for the listed PLM Component Type. It means that your implementation can safely use the PLM attributes of the default PLM Component.
PLM Component Class Types |
---|
PLMCoreReference |
PLMCoreRepReference |
Parameter Names | Types | Read/Write | Comments |
---|---|---|---|
ThisObject | PLMEntity | Read/Write | This is a PLM proxy object with the same top modeler type and custo type as the PLM entity to create on which attribute valuation is requested or this is a proxy object of the exported PLM entity from which data can be extracted. Reading this PLM entity, the BL can retrieve original attributes values. During 3DXML import, only custom attributes can be modified. They will be initialized to default value, and can be set to another value by the rule. In case of update, if the custom attribute is not explicitelly valuated by the rule, then the original value in database will be kept. |
OperationId | string | Read | Parameter used to identify the context of usage of the BL. Authorized
values are:
|
IdString | string | Read | Parameter used to pre-valuate the identifier attribute. This information comes from UI (Tools/Options). Can be interpreted as a prefix for instance. May be not used by the Business Logic |
iFileId | string | Read | Parameter valuated when OperationId="DataExchangeImport". Parameter used to pre-valuate the identifier attribute. This is the name of product reference or representation reference stored in file.This is an optional parameter for the other operations |
ExchangeInfo | feature | Read/Write | Parameter valuated when OperationId="BriefcaseImport" or "BriefcaseExport". This parameter is used to describe additional information associated to an exported PLM object. It contains a set of (key, value) couples. Key and values are strings, and they are freely-defined by the administrator creating the rules (usually based on an agreement between the emitter and the reciever). This parameter is meant to be filled at export (OperationId="BriefcaseExport) and read at import (OperationId="BriefcaseImport). |
FirstImport | boolean | Read | Parameter valuated when OperationId="BriefcaseImport" or "FBDIImport" This parameter specifies if the object is imported for the first time (meaning this is an initialization), or if it already exists in the database (meaning this is an update). This parameter can be used by rules that need to initialize custom attribute values at first import only. |
oReferenceId | string | Read/Write | Parameter valuated when OperationId="DataExchangeExport". Parameter used to pre-valuate identifier attribute of File. This is an optional parameter for the other operations |
FileName | string | Read | Parameter valuated when OperationId="FBDIImport". This parameter is used to retrieve the name of the file being imported. Ex : If E:\tmp\Rotor.CATPart is imported FileName is worth Rotor. |
FileType | string | Read | Parameter valuated when OperationId="FBDIImport". This parameter is used to retrieve the type of the file, ( CATPart, CATproduct, CATDrawing …) being imported |
NativeV5Properties | feature | Read | Parameter valuated when OperationId="FBDIImport". This parameter is used to retrieve the list of the CATIA V5 native properties. The content of this list depends on the modeller type to which the proxy (ThisObject) belongs . Each modeller exposes a given and frozen list of properties that will be transmitted to the script of the Business Logic. [2] |
UserV5Properties | feature | Read | Parameter valuated when OperationId="FBDIImport". This parameter is used to retrieve the list of the CATIA V5 user properties. The content of this list depends on the modeller type to which the proxy (ThisObject) belongs. Each modeller exposes or not this list that could be transmitted to the script of the Business Logic. [1] |
The following BL samples show how to:
To achieve this particular business logic implementation, a CATRuleExit file, known as family, declares the script to run each time a PLM Import/Export command is started:
<Scripts> <Script OpeningID="PLMImportExportAttributesValuation" Type="MyCustoType" ScriptName="MyRepDataExchangeImportScript"> <Condition Attribute="OperationId" Value="DataExchangeImport" /> </Scripts> <Script OpeningID="PLMImportExportAttributesValuation" Type="MyCustoType" ScriptName="MyRepDataExchangeExportScript"> <Condition Attribute="OperationId" Value="DataExchangeExport" /> </Scripts> <Script OpeningID="PLMImportExportAttributesValuation" Type="MyCustoType" ScriptName="My3DXMLImportScript"> <Condition Attribute="OperationId" Value="BriefcaseImport" /> </Scripts> </Scripts> <Script OpeningID="PLMImportExportAttributesValuation" Type="MyCustoType" ScriptName="My3DXMLExportScript"> <Condition Attribute="OperationId" Value="BriefcaseExport" /> </Scripts> </Scripts> <Script OpeningID="PLMImportExportAttributesValuation" Type="MyCustoType2" ScriptName="My3DXMLImportScript2"> <Condition Attribute="OperationId" Value="BriefcaseImport" /> </Scripts>
This family references the script that contains the business logic implementation, which looks like the following CATRule file:
Sample 1 (MyRepDataExchangeImportScript.CATRule) :
The script is based on a user knowledge package which provides a function DateFormat to get a time stamp.
Let Name(string) Name = "" if (Parameters->HasAttribute("iFileId")== true) { Name = Parameters->GetAttributeString("iFileId") } if(Name <> "") { if ( ThisObject->HasAttribute("V_Name") == true ) { ThisObject.V_Name = Name } ThisObject.PLM_ExternalID = Name + "_" + DateFormat("%Y-%m-%d_%Hh%M") }
Sample 2 (MyRepDataExchangeExportScript.CATRule) :
Let Name(string) Name = "" if (Parameters->HasAttribute("oReferenceId")== true) { if ( ThisObject->HasAttribute("PLM_ExternalID") == true ) { Name = ThisObject.PLM_ExternalID } Parameters->SetAttributeString("oReferenceId",Name) }
Sample 3 (My3DXMLImportScript.CATRule) :
Let Name(string) Name = "" if (Parameters->HasAttribute("FirstImport")== true) { if ( Parameters->GetAttributeBoolean("FirstImport") == true ) { if (ThisObject->HasAttribute("PLM_ExternalID")== true) { Name = ThisObject.PLM_ExternalID } ThisObject->SetAttributeString("MyCustomAttribute",Name) } }
Sample 4 (My3DXMLExportScript.CATRule) :
Let Value(string) Let ExInfo(feature) Value = "sampleValue" if (ThisObject->HasAttribute("MyCustomAttribute")== true) { Value = ThisObject.GetAttributeString( "MyCustomAttribute" ) } if (Parameters->HasAttribute("ExchangeInfo") == true) { ExInfo = Parameters->GetAttributeObject("ExchangeInfo") ExInfo->SetAttributeString( "sampleKey", Value ) }
Sample 5 (My3DXMImportScript2.CATRule) :
Let Value(string) Let ExInfo(feature) Value = "sampleValue" if (Parameters->HasAttribute("ExchangeInfo") == true) { ExInfo = Parameters->GetAttributeObject("ExchangeInfo") if (ExInfo->HasAttribute("sampleKey") == true) { Value = ExInfo->GetAttributeString( "sampleKey" ) } } ThisObject.SetAttributeString( "MyOtherCustomAttribute", Value )
Before using an input parameter, you have to check its value. For instance, to check if the iFileId parameter is valuated or not, use the following code sequence:
... if (Parameters->HasAttribute("iFileId")== true) Name = Parameters->GetAttributeString("iFileId") if(Name <> "") { ...
A typical usage of the IdString parameter is to interpret it as a prefix.
[1] | Availability of V5 Properties through FBDI Business Logic |
Version: 1 [January 2008] | Document created |