Whats new in updated script in 2024?
1. The script now supports creation of "Continuous" types of Mfg. Items. For example: Continuous Manufactured Material, Continuous Provided Material
2. Improvements are done in the algorithm of the script.
Introduction
This document intended to provide a detailed guide and examples on how to write EKL script to import Mfg. Item structure from Excel.
Version – Validated on 2021x FD09 (FP2140), 2022x FD01 (FP2205), 2023x FD02 (FP2314), 2024x FD02 (FP2414), 2025x FD03 (FP2524)
Pre-requisites:
Licenses –
- CSV(Collaborative Industry Innovator)
- MDG(Mechanical Designer)
- PPL(Process Engineer)
- KDI(Template Designer)
Disclaimer: Licenses mentioned above are as per 2021x, 2022x, 2023x, 2024x & 2025x documentation.
Logical Flow
Below is the logical flow for Import Mfg. Item Structure EKL script:
Example
Detail Explanation
Template Excel format
The template excel format is as given below:
The 1st 5 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
|
Magnitude | Magnitude is only required for the Mfg. Items of type "Continuous" (ProcessContinuousProvide & ProcessContinuousCreateMaterial)
|
Title | V_Name of Object created |
Inst_Name | V_Name of Object Instance created |
Linked_Product | Linked product instance name to link with created Mfg. Item. 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 exported then add “Inst_” keyword before attribute name. For example for instance V_description, it will be “Inst_V_description”
How to manage Multi-Instantiation
Steps followed for managing Multi-Instantiation:
Note: 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.
- Check if the reference with V_Name of item to be created is already available in Dictionary of existing objects.
- If the reference is not created previously, create a new reference and add it Dictionary of existing object. Set attributes of new objects reference and instance.
- 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 attached EKL script, user can find the code between below two comments. This code is responsible to manage multi-instantiation as described above.
/*-----------------Code to Manage Multi-Instantiation starts here--------------*/
.
.
/*--------------Code to Manage Multi-Instantiation Ends----------------*/
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 5. 1st 5 columns are reserved for Level, Object type, Title, Instance name and Linked Products. 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.
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.
/*Below code will set additional OOTB/specialized attributes from column number 6 onwards*/
.
.
/* Setting specialized/custom attributes is finished */
Assign the Product items to Mfg Item (Linked Product)
The steps followed to assign the product to the Mfg. item are as follows:
- Get the string of linked products from excel. (Done at start of every iteration on excel row)
- After creating Mfg. item, check if the string of linked product is set or not.
- If the string have some value, run a query on Root Product to get Occurrence of Product items with Instance Names as mentioned in excel and assign them to the Mfg. item.
The code given below is responsible to assign the products to Mfg. item:
// Search linked product no. inside structure and create link between Mfg item and product/part.
if strLinkedProds <> ""
{
strSearch = "x.GetAttributeObject(\"Instance\").GetAttributeString(\"PLM_ExternalID\") ==" + " \"" + strLinkedProds + "\""
oListOfVPMReference = oRootVPMOcc->Query("ProductOccurrence", strSearch)
// check if object is present in session if yes get its occ
If oListOfVPMReference.Size() > 0
{
let oVPMOcc(ProductOccurrence)
oVPMOcc = oListOfVPMReference->GetItem(1)
// Create implement link between product and mfg item.
if oVPMOcc <> NULL
oChildMfgProcOcc->AssignProduct(oVPMOcc)
}
}
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 .xlsx
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 .xlsx
strTempFileName = " MID_Structure_ " + strTemp3 + ".xlsx"
//For .csv
strTempFileName = " MID_Structure_ " + strTemp3 + ".csv"
2. Requirement 2: Use Display Name as Object Type instead of Internal Type
The "Type" of object is provided in the "Type" column of the template excel.
In the excel file, instead of specifying OOTB Type, different keywords may be used for the "Type" of the object. In the provided EKL script, mapping is done for some keywords and intern object type to be used for that keyword. For example, "Manufacturing Assembly" for "CreateAssembly" and "Provided Part" for "Provide".
If user wants to use custom keywords for other types of objects instead of Internal Object type, then the mapping for that object's custom keyword l and internal object type must be added in the below lines of the code available in the provided script:
//2. Excel value and internal object type mapping
if strType == "Manufacturing Assembly"
strType = "CreateAssembly"
else if strType == "Provided Part"
strType = "Provide"
else if strType == "DMDDE1CustomMfgAsm"
strType = "DMDDE1CustomMfgAsm"
else if strType == "CreateMaterial" or strType == "CreateKit" or strType == "CreateAssembly" or strType == "ElementaryEndItem" or strType == "Fasten" or strType == "Marking" or strType == "Provide" or strType == "Split" or strType == "Installation" or strType == "PreDrill" or strType == "Drill" or strType == "NoDrill" or strType == "Cutting" or strType == "Grinding" or strType == "Beveling" or strType == "Transform" or strType == "ProcessContinuousProvide" or strType == "ProcessContinuousCreateMaterial"
strType = strType
else
{
PopupMessage("INVALID Type : please enter valid type in input excel file for Row - # and Col - #|| Script execution is terminitated!", indx, 2)
break
}
Note: The "new()" function also supports creation of custom types of objects. Please add the mapping for the custom objects keyword and Internal Type in the EKL Script
Note: To know more about the "new()" function, visit this page
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" or strAttrName == "description"
{
strAttrName = "V_description”
}
else if strAttrName == "Inst_Description " or strAttrName == " Inst_description"
{
strAttrName = “Inst_” + "V_description"
}
//for attributes of instance objects “Inst_” is added to the internal name
How to Deploy
This video describes: How to deploy the "Import Product Structure from Excel?" EKL Script. However, the process is same for following EKL Scripts:
1. Import Resource Structure from Excel
2. Import Mfg. Item Structure from Excel
3. Import System Structure from Excel
(Note:
1. Instead of creating a separate Physical Product for containing each script, you can create the action files for the above three EKL scripts in the same Physical Product that we are going to create for "Import Product Structure from Excel" EKL Script.
2. The Excel File Selector VBScript is same for all the above EKL Scripts. So, you can create it only once and use it in all the above EKL Scripts.
3. The input arguments are different for different type of structure script. The information is provided in the respective EKL script as a comment at the top section.
)
References link
<
Author
Authors: @KA @RR @YB
For any queries, please contact - @KA