How to Implement the Import Export Attributes Valuation Business Logic?

Technical Article

Abstract

This article details how you can implement the Import Export Attributes Valuation Business Logic based on the knowledge scripting technology.

Business Logic Intent

This business logic can be invoked in 2 different contexts:

  1. During an import: the business logic allows to customize the valuation of the public PLM attributes on imported PLM entities,
  2. Export context: the business logic allows to extract information from the public PLM attributes of the exported PLM entities.

 This Business Logic is called:

  1. In the PLM Export File command for file attributes valuation. Public PLM attributes of the Component can be used to pre-valuate the File Reference Id,
  2. In the PLM Import File command to initialize mandatory attributes or customize the free PLM attributes by reading the input file information,
  3. In the 3DXML Export command to add freely-defined information to exported objects' description
  4. In the 3DXML Import command to initialize of update custom attributes on imported objects

PLM Opening Definition

This section describes the objects defining the PLM opening: its global information, its kind of input object, its context object parameters.

General Information

PLM Opening ID PLMImportExportAttributesValuation
Customization Intent Execution
Execution Context Client

Input Objects

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

Context Object Parameters

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:
  • "DataExchangeExport”for PLM Export File command,
  • "DataExchangeImport" for PLM Import File command,
  • "BriefcaseImport" for 3DXML Import command,
  • "BriefcaseExport" for 3DXML Export command,
  • "FBDIImport" for FBDI Import command.
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]

 

 

Implementation Sample

The following BL samples show how to:

  1. initialize the naming of a Representation Reference from the naming of a File containing only geometry (PLM_ExternalID attribute is suffixed by a time stamp)
  2. initialize the naming of a File from the naming of a Representation Reference as PLM_ExternalID value.
  3. initialize the value of a custom attribute from the PLM_ExternalID value, during a 3DXML Import.
  4. add a freely-defined export information based on a custom attribute value, during a 3DXML Export.
  5. use this freely-defined information to valuate another custom attribute, during a 3DXML Import.

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 )

Recommendations

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.

References

[1] Availability of V5 Properties through FBDI Business Logic

History

Version: 1 [January 2008] Document created