Import System Structure From Excel using EKL

ThoughtWorthSharing ​​​​​​​HowTo ​​​​​​​

Introduction

This document intended to provide a detailed guide and examples on how to write EKL script to import System Structure from Excel

Version – 2022x FD03

Pre-requisites:

Licenses

  • CSV(Collaborative Industry Innovator)
  • PPL(Process Engineer)
  • TER (Templates & Rules Designer) only for authoring

Documented by: Kunal AGLAVE

Disclaimer: Licenses mentioned above are as per 2022x documentation.

Logical Flow

Below is the logical flow for Import System Structure EKL script:


Example

The presentation contains

1. Script file

2. Sample example input file

3. Step - by - Step video for executing the video


​​​​​​​



Detailed Explanation

Excel template for Importing Resource Structure

The template excel format is as shows below:


The 1st 7 columns are reserved and necessary to be added. Their description is as given below:

Column Title

Significance

Level

Defines level of object inside structure,

1 – Root

2 – First level child of root or child of level 1.

3 – Second level child of root or child of level 2.

N – Child of level N – 1.

Type

Type of object to create

Title

V_Name of Object created

Inst_Name

V_Name / PLM_ExternalID of Object Instance created

Precedence_Link

Precedence link created between operations instance and material flow for system instance

Can give multiple “;” separated instance names.

MID_Link

MfgItem instance name to link with created Operation.

Can give multiple “;” separated instance names.

Resource_Link

Resource instance name to link with created Operation.

Can give multiple “;” separated instance names.

Additional attributes

All other attributes (Internal name) to be set on created Object’s reference and instance.

Note: If instance attributes value needs to be set then add “Inst_” keyword before attribute name. For example for instance description, it will be “Inst_V_description”

How to manage Multi-Instantiation

Steps followed for managing Multi-Instantiation:

In the script, every time an new object is created, its reference is added in dictionary (Volatile instance) with V_Name(strPartNo) used as its key. This is useful for multi-instantiation.

  1. Check if the reference with V_Name (strPartNo) of item to be created is already available in Dictionary of existing objects.
  2. If the reference is not created previously, create a new reference and add it Dictionary of existing object. Create its instance with specified instance name. Set attributes of new objects reference and instance.
  3. If the reference with V_Name of item to be created is available in dictionary, extract it and create its new instance. Set the attributes of newly instantiated object.

In the attached EKL Script, code between below comments is responsible to support multi-instantiation

/*---------------------------------------Section to support multi-instantiation -------------------*/
.
.
/*---------------------------------------End of Section to support multi-instantiation ------------*/

How to set additional attribute and other custom attributes:

To set other extra attributes of the created objects, add extra columns in the excel file after column 7. 1st 7 columns are reserved for Level, Object type, Title(Reference Name), Instance name, Precedence link, MID Link and Resource link. While creating the column, column name should be the attribute name. Add the values in respective rows. While setting the column name for attribute of instance object, add “Inst_” as a prefix in the column name.

The EKL script manages to set the additional attributes if they are specified in the excel file. The condition is, the attribute should be available on the object. User can specify custom attributes also if available.

For example: Additional attributes to be set are highlighted in red box.


The code between below comment lines in attached EKL script is responsible for setting additional and custom attributes. It set both reference and instance object attributes.

//Logic to read remaining columns and set additional attributes
.
.
//End of for loop to set Additional Attributes

Creation of Implement Link or Resource Link:

The explanation for creating implement link/Resource is given below.

  • For each MID/Resource object to be linked, run a Query on Root MID/Root resource to search item with Instance Name same as the item name specified in excel.
  • Get the Mfg Item/Resource item with specified Instance name and assign it to the System object.

If the user wants to modify the logic for creation of Implement Link, modify section of code between comments given below

//-----START Mfg Item Implement link-----
.
.
//-----End Mfg Item Implement link-----

If the user wants to modify the logic for creation of Resource Link, modify section of code between comments given below

//-----START Resources Implement Link-----
.
.
//-----END Resources Implement Link-----

Creation of Precedence Link:

Precedence Link is created at the end after creating whole System Structure. A query is executed on Root System to get the Occurrence of System object to be linked. If both the objects are of type, General System, Material Flow is created. If both the objects are of Operation type, Time Constraint is created.

To modify the logic for precedence link, modify the code between below comments.

//-----START precedence link-----
.
.
//-----END precedence link-----

Here under some Use Case about possible adaptation of the script

1. Requirement 1: Support CSV input file type.

To support .csv file type instead of .xlsx, follow bellow steps:

  • Edit below string in the VBScript:

In the script, strFileName string specifies the input excel file type. Modify the extension of the file name to .csv

'For .xslv
strFileName = CATIA.FileSelectionBox("Select the input Excel File", "*.xlsx", CatFileSelectionModeOpen)

'For .csv
strFileName = CATIA.FileSelectionBox("Select the input Excel File", "*.csv", CatFileSelectionModeOpen)
  • In the EKL script, make following changes:

In the EKL script, strTempFileName variable of string type specifies the type of excel file to be created. Modify the below lines of code

//For .xslv
strTempFileName = "SystemStructure_" + strTemp3 + ".xlsx"

//For .csv
strTempFileName = "SystemStructure_" + strTemp3 + ".csv"

2. Requirement 2: Use Display Name as Object Type instead of Internal ObjectType

If the user wants to use Display Name as Type of the object instead of Internal Object type, add below lines of code after reading the attributes from the excel. Eg. If user want to specifi “General System” instead of “DELLmiGeneralSystemReference”.

/* This section is to read object type from column "Type" */
If strObjType == "General System"
          strObjType = "DELLmiGeneralSystemReference"
else if strObjType == "Workplan System"
          strObjType = "DELLmiWorkPlanlSystemReference"
else If strObjType == "Loading Operation"
          strObjType = "DELLmiLoadingOperationReference"
else If strObjType == "General Operation"
          strObjType = "DELLmiGeneralOperationReference"
          // Specialized data type
else if strObjType =="DMDDE1CustoGenOpr"
          strObjType = "DMDDE1CustoGenOpr"
else
          PopupMessage("INVALID Type: given type is not supported please modify script to support it")
/* similarly add if statements for custome object types */

3. Requirement 3: Use custom column names instead of internal attribute name

If the user wants to use custom column names instead of internal attribute name, for example:

Here “description” is used instead of “V_description”


Add below line of code in the EKL script, where additional/custom attribute values are read from the excel file.

if strAttrName== " description "
{
   strAttrName = "V_ description”
}
else if strAttrName == "Instance description"
{
   strAttrName = "Inst_V_description"
}

4. Requirement 4: Add WorkPlan instead of GeneralSystem.

If user wants to create WorkPlan instead of GeneralSystem, do below changes in the Attached EKL script.

Change the input argument name “oRootSysOcc” to “oRootWorkPlanOcc”. Occurrence type is same as General system, which is “ProdSystemOccurrence”. Only the reference of Work Plan have different Object Type.

  • Declare below variable to store WorkPlan references.
//Variable to store root Workplan system references
Let oRootWorkPlanRef(DELLmiWorkPlanSystemReference)
Let oWorkPlanSysRef(DELLmiWorkPlanSystemReference)  // stores refrence of Workplan system
  • Create scope between RootWorkPlan and Root MID.
oRootWorkPlanOcc.CreateScope(oRootFProcOcc)

Create scope between Root Resource and RootWorkPlan.

oRootResOccurrence.CreateScope(oRootWorkPlanOcc)
  • Add below code in the section of script, where Object Types from Excel are mapped to Internal Types. This will map WorkPlanSystem’s internal reference type.
else If strObjType == "Work Plan"
               strObjType = " DELLmiWorkPlanSystemReference "
  • Add below code in section of script, where new objects are created or instantiated. This will manage to create object of WorkPlanSystem type.
else If strObjType == " DELLmiWorkPlanSystemReference "
{
      /* Inserting the existing Workplan system under respective parent Workplan system and storing it
      in the respective variable */      
      Set oWorkPlanSysRef = oPLMCoreReference
      Set oProdSysOcc =  oParentProdSysOcc.InsertExistingSystem(oWorkPlanSysRef)
}
  • Add below code in section of script, where, precedence link is created. This will create material flow between two workplans.
else if strSuccessorModelerName == " DELLmiWorkPlanSystemReference " and strPredModelerName                == "DELLmiWorkPlanSystemReference"
{
   //if there are two WorkPlan Systems back to back, create a material flow
   oProdSysOccPrec.CreateMaterialFlow(PredProdOcc)
}