EKL - Techno Table Compute values

Context

When defining Techno table in Engineering Specification Application you may want to automate the valuation of a column based on the concatenation or computation from other columns

the following exemple illustrates how to valuate the Pipe Name column in the Pipe reference Dimension table based on other columns like illustrated in the following picture

 

Case1 : Compute the Pipe name in the Pipe Ref Dimension table

Video:

Data: 

 

Code Example :

/* Input:  pTechnoTable : PipReferenceDimensionTable */
/* OR Input:  pTechnoTable : PipCustomerAdvancedTable */

/* Declarations of Variables */
let NbRows    (Integer)
let NbColumns (Integer) 
let res  (Boolean)
let i(Integer)
let j(Integer)
let StringValue1(string)
let NbAttribute (Integer)
let ColumnIndex (Integer)
let NameHeaderColumn (string)
let index (integer)
let FullName (string)
let NbEnsParameterDescriptors (integer)
let RealValue1 (Real)
let HeaderType (string)

let pCell (EnsTechnologicalTableCell)
let pReadCell (EnsTechnologicalTableCell)
let pEnsParameterDescriptor (EnsParameterDescriptor)
let ListCell (List)
let ListRowCell (List)
let ListColumnNumber (List)
let EnsParameterDescriptors (List)
let ListTypecolumn (List)

let LengthValue(Length)

/* Read ens techno table size : number of rows and columns */
res = pTechnoTable->GetSize(NbRows, NbColumns)

Trace(1,"Eng Spec Rule : GetSize : NbRows    = ", NbRows)
Trace(1,"Eng Spec Rule : GetSize : NbColumns = ", NbColumns)

/* Following a rule based on the Name of header, build the order of column that  */
/* you will use to build the name of the Part                                                                  */
/* -----------------------------------------------------------------------------------*/

res = pTechnoTable->GetColumnDefinitions(EnsParameterDescriptors)

NbEnsParameterDescriptors = EnsParameterDescriptors.Size()
j = 1
if (0 < NbEnsParameterDescriptors)
{
 for j while j <= NbEnsParameterDescriptors
 {
    Trace(1,"Eng Spec Rule : GetSpecificationContent : j = ", j)
    set pEnsParameterDescriptor = EnsParameterDescriptors.GetItem(j)
    if (NULL <> pEnsParameterDescriptor)
    {
      NameHeaderColumn = pEnsParameterDescriptor->GetAttributeString("Name")
      Trace(1,"Eng Spec Rule : GetSpecificationContent : EnsParameterDescriptor : Name = ",NameHeaderColumn)
    }
    
    if ("V_Name" == NameHeaderColumn)
    {
      ColumnIndex=12
      ListColumnNumber.Append(ColumnIndex)
      ListTypecolumn.Append("String")
      ColumnIndex=2
      ListColumnNumber.Append(ColumnIndex)
      ListTypecolumn.Append("String")
      ColumnIndex=5
      ListColumnNumber.Append(ColumnIndex)
      ListTypecolumn.Append("String")
      ColumnIndex=15
      ListColumnNumber.Append(ColumnIndex)
      ListTypecolumn.Append("String")
      ColumnIndex=6
      ListColumnNumber.Append(ColumnIndex)
      ListTypecolumn.Append("String")
      ColumnIndex=13
      ListColumnNumber.Append(ColumnIndex)
      ListTypecolumn.Append("String")
      ColumnIndex=26
      ListColumnNumber.Append(ColumnIndex)
      ListTypecolumn.Append("String")
      //ColumnIndex=10
      //ListColumnNumber.Append(ColumnIndex)
      //ListTypecolumn.Append("Real")
    }
  }
}

/* Build the name */
/* ------------------------------------------*/

/* Loop on row */
NbAttribute = ListColumnNumber->Size()
i=1
for i while i <= NbRows
{
  /* Prefix on Part Name */
  //FullName = "DS_Part_"
  FullName = ""
    
  /* Retreieve the row value */
  res = pTechnoTable->GetRow(i, ListRowCell)

  /* Loop on Column to build the Name */
  j=1
  for j while j <= NbAttribute
  {
    set index = ListColumnNumber.GetItem(j)
    set pReadCell = ListRowCell.GetItem(index)
    set HeaderType = ListTypecolumn.GetItem(j)
    if (NULL <> pReadCell)
    {
      if ("String" == HeaderType)
      {
        StringValue1 = pReadCell->  GetAttributeString("ValueAsString")
      }

       if ("Real" == HeaderType)
      {
        RealValue1 = pReadCell-> GetAttributeReal("ValueAsReal")
        LengthValue = RealValue1
        StringValue1 = DimToString(LengthValue, "mm")
      }

    }
    set FullName = FullName + StringValue1 
    if (j < NbAttribute)
    {
       set FullName = FullName + "_"
    }
  }

  /* Add an increment Number at the end */
 // StringValue1 = ToString(i)
  //set FullName = FullName + "-" + StringValue1

  /* Create a Cell to store the name of Part */
  pCell = new ("EnsTechnologicalTableCell",FullName,NULL)
  if (NULL <> pCell)
  {
    pCell->   SetAttributeString("ValueAsString",FullName)
    ListCell->    Append(pCell)
  }
}

/* Set the name on the targeted Column */
/* --------------------------------------------------------*/

ColumnIndex = 1
res = pTechnoTable-> SetColumn(ColumnIndex,ListCell)

if (true == res)
{
  Message("The name is generated properly")
}
txt file