Manage Catalog object names during 3DXML import as New

Context

When importing catalog "as new reference" through 3DXML, the OOTB default rules is remaming all the entities (Catalog, chapter, items) with an additionnal suffix

This can be painfull if you have other commands or script that works on the Catalog object names

To avoid this , you can set BL inside the Datasetup to control the name at creation

Here are some sample for the 3 object types  (Catalog, chapter, items). these BL are attach to a Resource set and must be Deploy on the Collab space on which you want to import the data later on 

Datasetup Resource Set : 

  • Business Logic implementation

Datasetup Resource : 

  • Attribute Initialization

 

Sample

Usage of the BL with the 3DXML sample

When using this BL with the Following option, the name will be the same as the original file

 

BUT if you add a Duplication string during import then the BL will use it as a suffix and add also a unique identifier increment

 

Content description:

ResourceSet to attach to project

 

BL inside the Resource Set dedicated to catalog

 

BL code:

for Catalog

Let Prefix(String)
Let ObjectCustoType=""
Let UniqueKeyForCustoType=""
Let Operation=""
Let CopyFromId=""
Let IDNumber(Integer) 
Let CopyFrom (ENOCLG_LibraryReference)
if( Parameters->HasAttribute("CustoType") == true) {
  ObjectCustoType = Parameters->GetAttributeString("CustoType")
}
if( ObjectCustoType == "") {
  Parameters.Message="'CustoType' attribute must be available in in RuleContext parameters"     
  UniqueKeyForCustoType="NoUniqueKey"
}
else {
  UniqueKeyForCustoType = GetUniqueKey( ObjectCustoType )
}
Operation=Parameters->GetAttributeString("OperationId")
if (Operation=="ImportAsNew")
{
    if (Parameters->HasAttribute("IdCloningString") == true)
       {
        Prefix = Parameters->GetAttributeString("IdCloningString")
    }
    if Prefix==""
    {
        Prefix = Parameters->GetAttributeString("IdString")
     }
    if (Prefix <> "") 
     { 
         set CopyFrom = Parameters->GetAttributeObject("CopyFrom")
         CopyFromId = CopyFrom->GetAttributeString("PLM_ExternalID")
         ThisObject.PLM_ExternalID = CopyFromId + Prefix + UniqueKeyForCustoType
    }
    else
    {
        set CopyFrom = Parameters->GetAttributeObject("CopyFrom")
         CopyFromId = CopyFrom->GetAttributeString("PLM_ExternalID")
        /* overwritten to allow import without suffix for sample catalogs
        ThisObject.PLM_ExternalID = CopyFromId + "-" + UniqueKeyForCustoType 
        */
        ThisObject.PLM_ExternalID = CopyFromId 
    }
}
else if (Operation=="Cloning")
{
    Prefix=""
    Prefix = Parameters->GetAttributeString("IdCloningString")
    if (Prefix<>"")
    {
        set CopyFrom = Parameters->GetAttributeObject("CopyFrom")
         CopyFromId = CopyFrom->GetAttributeString("PLM_ExternalID")
        ThisObject.PLM_ExternalID = Prefix + CopyFromId
    }
    else
    {
        Prefix = Parameters->GetAttributeString("IdString")
         set CopyFrom = Parameters->GetAttributeObject("CopyFrom")
         CopyFromId = CopyFrom->GetAttributeString("PLM_ExternalID")
         ThisObject.PLM_ExternalID = Prefix + CopyFromId + UniqueKeyForCustoType
    }
}
else
    /* (Operation=="New" or Operation=="Implicit" or Operation=="Default")*/     
{ 
    Prefix=""
    if (Parameters->HasAttribute("IdString") == true) 
    {
           Prefix = Parameters->GetAttributeString("IdString")
           if (Prefix == NULL) Prefix = ""
    }
    ThisObject.PLM_ExternalID = Prefix + "Catalog" + UniqueKeyForCustoType
    
}

 

For Chapters:

Let Prefix(String)
Let ObjectCustoType=""
Let UniqueKeyForCustoType=""
Let Operation=""
Let CopyFromId=""
Let CopyFrom (ENOCLG_ClassReference)

if( Parameters->HasAttribute("CustoType") == true) {
  ObjectCustoType = Parameters->GetAttributeString("CustoType")
}
if( ObjectCustoType == "") {
  Parameters.Message="'CustoType' attribute must be available in in RuleContext parameters"     
  UniqueKeyForCustoType="NoUniqueKey"
}
else {
  UniqueKeyForCustoType = GetUniqueKey( ObjectCustoType )
}
Operation=Parameters->GetAttributeString("OperationId")
if (Operation=="ImportAsNew")
{
    if (Parameters->HasAttribute("IdCloningString") == true)
   {
        Prefix = Parameters->GetAttributeString("IdCloningString")
    }
    if Prefix==""
    {
        Prefix = Parameters->GetAttributeString("IdString")
     }
    if (Prefix <> "") 
     { 
         set CopyFrom = Parameters->GetAttributeObject("CopyFrom")
         CopyFromId = CopyFrom->GetAttributeString("PLM_ExternalID")
         ThisObject.PLM_ExternalID = CopyFromId + Prefix + UniqueKeyForCustoType
    }
    else
    {
        set CopyFrom = Parameters->GetAttributeObject("CopyFrom")
         CopyFromId = CopyFrom->GetAttributeString("PLM_ExternalID")
        /* overwritten to allow import without suffix for sample catalogs
        ThisObject.PLM_ExternalID = CopyFromId + "-" + UniqueKeyForCustoType
        */
        ThisObject.PLM_ExternalID = CopyFromId 
    }
}
else if (Operation=="Cloning")
{
    Prefix=""
    Prefix = Parameters->GetAttributeString("IdCloningString")
    if (Prefix<>"")
    {
        set CopyFrom = Parameters->GetAttributeObject("CopyFrom")
         CopyFromId = CopyFrom->GetAttributeString("PLM_ExternalID")
        ThisObject.PLM_ExternalID = Prefix + CopyFromId
    }
    else
    {
        Prefix = "Copy Of " /*Parameters->GetAttributeString("IdString")*/
         set CopyFrom = Parameters->GetAttributeObject("CopyFrom")
         CopyFromId = CopyFrom->GetAttributeString("PLM_ExternalID")
         ThisObject.PLM_ExternalID = Prefix + CopyFromId /*+ ToString(Parameters->GetAttributeInteger("IncSessionId"))*/
    }
}
else
    /* (Operation=="New" or Operation=="Implicit" or Operation=="Default")*/     
{ 
    Prefix=""
    if (Parameters->HasAttribute("IdString") == true) 
    {
           Prefix = Parameters->GetAttributeString("IdString")
           if (Prefix == NULL) Prefix = ""
    }
    ThisObject.PLM_ExternalID = Prefix + "Chapter" + UniqueKeyForCustoType
}

 

for Catalog Item

Let Prefix(String)
Let ObjectCustoType=""
Let UniqueKeyForCustoType=""
Let Operation=""
Let CopyFromId=""
Let CopyFrom (ENOCLG_Item)

if( Parameters->HasAttribute("CustoType") == true) {
  ObjectCustoType = Parameters->GetAttributeString("CustoType")
}
if( ObjectCustoType == "") {
  Parameters.Message="'CustoType' attribute must be available in in RuleContext parameters"     
  UniqueKeyForCustoType="NoUniqueKey"
}
else {
  UniqueKeyForCustoType = GetUniqueKey( ObjectCustoType )
}
Operation=Parameters->GetAttributeString("OperationId")
if (Operation=="ImportAsNew")
{
    if (Parameters->HasAttribute("IdCloningString") == true)
   {
        Prefix = Parameters->GetAttributeString("IdCloningString")
    }
    if Prefix==""
    {
        Prefix = Parameters->GetAttributeString("IdString")
     }
    if (Prefix <> "") 
     { 
         set CopyFrom = Parameters->GetAttributeObject("CopyFrom")
         CopyFromId = CopyFrom->GetAttributeString("PLM_ExternalID")
         ThisObject.PLM_ExternalID = CopyFromId + Prefix + UniqueKeyForCustoType
    }
    else
    {
        set CopyFrom = Parameters->GetAttributeObject("CopyFrom")
         CopyFromId = CopyFrom->GetAttributeString("PLM_ExternalID")
        /* overwritten to allow import without suffix for sample catalogs
        ThisObject.PLM_ExternalID = CopyFromId + "-" + UniqueKeyForCustoType 
        */
        ThisObject.PLM_ExternalID = CopyFromId 
    }
}
else if (Operation=="Cloning")
{
    Prefix=""
    Prefix = Parameters->GetAttributeString("IdCloningString")
    if (Prefix<>"")
    {
        set CopyFrom = Parameters->GetAttributeObject("CopyFrom")
         CopyFromId = CopyFrom->GetAttributeString("PLM_ExternalID")
        ThisObject.PLM_ExternalID = Prefix + CopyFromId
    }
    else
    {
        Prefix = "Copy Of " /*Parameters->GetAttributeString("IdString")*/
         set CopyFrom = Parameters->GetAttributeObject("CopyFrom")
         CopyFromId = CopyFrom->GetAttributeString("PLM_ExternalID")
         ThisObject.PLM_ExternalID = Prefix + CopyFromId /*+ ToString(Parameters->GetAttributeInteger("IncSessionId"))*/
    }
}

 

3DXML TEST Data

contain a small catalog to test the BL