EKL - Compute new position of route points for merge operation

Introduction

Usage : During merge operation between 2 pipes you can parametrize the way the 2 pipe will be connected

like :

  • the extremity of the second pipe move to the position of the extremity of the first pipe
  • extend the pipe extremity and create new point to have 90deg (or 45deg) angle (if pipe are not aligned) 
  • ...

Datasetup Resource Set : 

  • Piping/Tubing Specification Resources
  • HVAC Specification Resources
  • Raceway Specification Resources

Datasetup Resource : Compute new position of route points for merge operation

 

Rule Example 1

Description

merging two pipes and the solution is that the merged route will be orthogonal to the slave route (note : the slave route is the second selected one)

Rule:

/* this sample rule is for merging two pipes and the solution is that the merged route will be orthogonal to the slave route */
/*Let SlaveRouteOcc(ProductOccurrence)*/        // not required for this sample
/*set SlaveRouteOcc = ThisObject*/

let MasterRoutePoint_attr = "MasterRoutePoint" /*List of MasterRoutePoint Coord */
let MasterRoutePoint_val (List)

let SlaveRoutePoint_attr = "SlaveRoutePoint" /*List of SlaveRoutePoint Coord */
let SlaveRoutePoint_val (List)

let MasterRouteVector_attr = "MasterRouteDirection" /*List of MasterRouteVector Coord */
let MasterRouteVector_val (List)

let SlaveRouteVector_attr = "SlaveRouteDirection" /*List of SlaveRouteVector Coord */
let SlaveRouteVector_val (List)

let MasterPtX (Real)
let MasterPtY (Real)
let MasterPtZ (Real)

let SlavePtX (Real)
let SlavePtY (Real)
let SlavePtZ (Real)

let MasterRouteVectorX (Real)
let MasterRouteVectorY (Real)
let MasterRouteVectorZ (Real)

let SlaveRouteVectorX (Real)
let SlaveRouteVectorY (Real)
let SlaveRouteVectorZ (Real)

set MasterRoutePoint_val = Parameters -> GetAttributeObject (MasterRoutePoint_attr)
MasterPtX = MasterRoutePoint_val.GetItem(1)
MasterPtY = MasterRoutePoint_val.GetItem(2)
MasterPtZ = MasterRoutePoint_val.GetItem(3)

set SlaveRoutePoint_val = Parameters -> GetAttributeObject (SlaveRoutePoint_attr)
SlavePtX = SlaveRoutePoint_val.GetItem(1)
SlavePtY = SlaveRoutePoint_val.GetItem(2)
SlavePtZ = SlaveRoutePoint_val.GetItem(3)

set MasterRouteVector_val = Parameters -> GetAttributeObject (MasterRouteVector_attr)
MasterRouteVectorX = MasterRouteVector_val.GetItem(1)
MasterRouteVectorY = MasterRouteVector_val.GetItem(2)
MasterRouteVectorZ = MasterRouteVector_val.GetItem(3)

set SlaveRouteVector_val = Parameters -> GetAttributeObject (SlaveRouteVector_attr)
SlaveRouteVectorX = SlaveRouteVector_val.GetItem(1)
SlaveRouteVectorY = SlaveRouteVector_val.GetItem(2)
SlaveRouteVectorZ = SlaveRouteVector_val.GetItem(3)

/*---------------------------------------------------------------------------------*/

/*----Logic for merging two parallel routes and obtaining 90 deg solution----*/ 

/*-----Vector xi + yj + zk joining the two extremities-----*/
let x (Real)
let y (Real)
let z (Real)
/*---------------------------------------------------------*/

set x = MasterPtX - SlavePtX
set y = MasterPtY - SlavePtY
set z = MasterPtZ - SlavePtZ

/*-------------Length of vector for projection-----------*/
let vectrlen (Real)
set vectrlen = (x * SlaveRouteVectorX) + (y * SlaveRouteVectorY) + (z * SlaveRouteVectorZ)
/*---------------------------------------------------------*/

let newx (Real)
let newy (Real)
let newz (Real)

set newx = vectrlen * SlaveRouteVectorX
set newy = vectrlen * SlaveRouteVectorY
set newz = vectrlen * SlaveRouteVectorZ

Let nSlavePt_attr = "newSlaveRoutePoint"
Let nSlavePt_val (List)

/*----New point obtained by projection method-----*/
nSlavePt_val.Append(SlavePtX + newx)
nSlavePt_val.Append(SlavePtY + newy)
nSlavePt_val.Append(SlavePtZ + newz)
/*-------------------------------------------------------*/

Let nMasterPt_attr = "newMasterRoutePoint"
Let nMasterPt_val (List)

nMasterPt_val.Append(MasterPtX)
nMasterPt_val.Append(MasterPtY)
nMasterPt_val.Append(MasterPtZ)

Let exMasterPt_attr = "extraMasterRoutePoint"    //Optional Output Parameter
Let exMasterPt_val (List)

//Do not append anything if no output is required
/*exMasterPt_val.Append(MasterPtX)            
exMasterPt_val.Append(MasterPtY)
exMasterPt_val.Append(MasterPtZ)*/

/*---------------------------------------------------------------------------------*/

/*-----------------------------------Outputs-------------------------------------*/
Parameters -> SetAttributeObject(nSlavePt_attr,nSlavePt_val)
Parameters -> SetAttributeObject(nMasterPt_attr,nMasterPt_val)
Parameters -> SetAttributeObject(exMasterPt_attr,exMasterPt_val)
/*---------------------------------------------------------------------------------*/