EKL - BL for automatic Space allocation

Introduction

Usage : Assign 3D space to Schematic Zones

Zone Name in schematic are defined into a XLS file that is attached to the Diagram Resource Set  in Data setup

3D space break down structure (GBS) is done with Space allocation App (SAO)

The rule will :

  • compute the objects that are in a Schematic zone (base on a critéria)
     
    • Zone can be closed contour or opened contour (down to a zone line ...)  
       
  • define the mapping between Schematic Zones and 3D spaces objects
     
  • create "Space Link" between all these 2D objects and the 3D space that correspond to the Zone
     

Datasetup Resource Set : 

  • Diagram Resource

Datasetup Resource : Rule for automatic Space allocation

 

Rule Example 1

Description:

The following rule is applicable for Zones with closed contour in Schematic.

nevertheless a part of the code which is in comment concerns the case if Zone are opened (based on Shipbuilding case)

In this exemple, Zone names and 3D Space object name must be the same 

Prereq : 
 

3D Space objects must have unique name in database, if there is two 3D space with same name, the rule will not work --> either you remove duplicated 3D Space from database or you add additionnal criteria into the rule to segregate the corresponding 3D space

Rule

/* CATRule signature (do not edit) : (ThisObject : #In LogicalOccurrence, Parameters : #In RuleContext) : #Void */

/* Sample rule*/
/* Input parameters are List of Zone Categories and List of Zone names*/
/* 1st Output parameter is a string by which we will search in database the space reference as Title*/
/* 2nd Output parameter is a ListOfList of Extension names which will be used to Build the Query (for reference attributes it will be empty string)*/
/* 3rd Output parameter is a ListOfList of Attribute names which will be used to Build the Query*/
/* 4th Output parameter is a ListOfList of Attribute values which will be used to Build the Query*/
/* All the ListOfLists are one to one mapping*/
/* Each List will be used to build a new query*/
/* Final No of spaces assigned will be addition of result of all queries*/  
/* Assuming the values we get in List_Zone_Categories are "Decks" and "Fire Zones" */
/* Assuming the values we get in List_Zone_Names are as "Deck02" and "Firezone 03"*/
/* Assuming we have four extenions i.e. "Organizational_Deck", "Organizational_FZ" "Organizational_Deck_FZ" and "Logical_Context"*/
/* Organizational_Deck" extension has attribute as "Deck_ID"(Integer)*/
/* Organizational_FZ" extension has attribute as "FZ_ID"(Integer)*/
/* Organizational_Deck_FZ" extension has attributes as "Deck_ID"(Integer) and "FZ_ID"(Integer)*/
/* Logical_Context" extension has attribute as "LA"(Boolean)*/
/* So we will create 3 lists of extensions, 3 lists of attributes names and 3 list of attribute values*/

/* First list of Extensions names will contain "Organizational_Deck" and "Logical_Context" */
/* First list of attributes names will contain "Deck_ID" and "LA" */
/* First list of attributes values will contain 2(int) and true(Boolean) */

/* Second list of Extensions names will contain "Organizational_FZ" and "Logical_Context" */
/* Second list of attributes names will contain "FZ_ID" and "LA" */
/* Second list of attributes values will contain 3(int) and true(Boolean) */

/* Third list of Extensions names will contain "Organizational_Deck_FZ", "Organizational_Deck_FZ" and "Logical_Context" */
/* Third list of attributes names will contain "Deck_ID", "FZ_ID" and "LA" */
/* Third list of attributes values will contain 2(int), 3(int) and true(Boolean) */

/* In this sample rule, we return the output string as "*" */
/* First Query will be build as Find all Spaces which has Extension as "Organizational_Deck" and "Logical_Context" and "Deck_ID" value is 2 and "LA" value is true*/
/* Sexond Query will be build as Find all Spaces which has Extension as "Organizational_FZ" and "Logical_Context" and "FZ_ID" value is 3 and "LA" value is true*/
/* Third Query will be build as Find all Spaces which has Extension as "Organizational_Deck_FZ" and "Organizational_Deck_FZ" and "Logical_Context" and "Deck_ID" value is 2
   and "FZ_ID" value is 3 and "LA" value is true*/

/* This rule is valid only for the data explained above */
/* User will have to modify this rule based on his/her Zone names, Zone Categories, Extensions names, Attribute names, Attibute values and Space References */

let This2DObject (LogicalOccurrence)
let ListZoneCategories(LIST)
let ListZoneNames(LIST)

set This2DObject = ThisObject
set ListZoneCategories = Parameters.GetAttributeObject ("List_Zone_Categories")
set ListZoneNames = Parameters.GetAttributeObject ("List_Zone_Names")

let OutputCENameListOfList(List)
let OutputCEAttrNameListOfList(List)
let OutputCEAttrValueListOfList(List)

Let attr_i(String)
Let i = 1
Let isize = 0
isize = ListZoneCategories->Size()

/* Get the values of Zone Categories*/
let OutputCEAttrNameLastList(List)   /* Last List Of Attributes names*/
let OutputCEAttrValueLastList(List)  /* Last List Of Attributes values*/
Let Customer_Ext(String)             /* To create extension of type Organizational_Deck_FZ*/

/* We are running the loop only upto 2 values since the metadata we created for test had only "Deck" and "FZ" types of extensions*/
/* If user has something more like "Organizational_W.T.Comp" then he must run the loop upto size of ListZoneCategories*/

let PLMReference(RFLVPMLogicalReference)
set PLMReference = This2DObject.Reference

Let attr_j(String)
Let j = 1
Let jsize = 0
jsize = ListZoneNames->Size()
Let output_str(String)

/*set output_str = ""*/

if(PLMReference.IsASortOf("EnsLogicalEquipment"))
{
    let index(integer)
    set index = ListZoneCategories->IndexOf("Zones",0)
    set output_str = ListZoneNames[index]    
}
else
{
    let index(integer)
    set index = ListZoneCategories->IndexOf("Zones",0)
    set output_str = ListZoneNames[index]    
}

/* Get the values of Zone names and create output string*/
/* Below code will create string as "Deck02_Firezone03" */
/*for j while j<=jsize
{
    set attr_j = ListZoneNames->GetItem(j)
  if(j < jsize)
  {
   set output_str = output_str + attr_j + "_"
  }
  else
  {
   set output_str = output_str + attr_j
  }
    j = j+1
}

/* We override the output_str as "*" to search by any name but with Extensions and Attributes */ 
/* If user wants to search from string as "Deck02_Firezone03", then comment the below line*/ 

/*set output_str = "*"+output_str*/

Parameters.SetAttributeString ("SpaceRefString", output_str)

Parameters.SetAttributeObject("List_Extension_Names", OutputCENameListOfList)

Parameters.SetAttributeObject("List_Attr_Names", OutputCEAttrNameListOfList)

Parameters.SetAttributeObject("List_Attr_Values", OutputCEAttrValueListOfList)