Business Rules

This section describes how you can customize the routing of logical connections by adding your own business rules.

Important: Business rules must be saved in the following location in the runtime view installation directory: /resources/knowledge/scripts

For more information about business rules, see Knowledge Expert User's Guide: Managing PLM Customization by Rules.

Related Topics
Using Business Rules

LFS_ValidateAllocationLogicalInstanceToEquipmentCenter

This validation rule will be triggered each time a Logical Instance is added or removed from the association to the selected Equipment Center.

ThisObject
Logical Instance to allocate or de-allocate.
Parameters

Standard context:


  • Severity: 1 (default) to raise a warning and the operation can continue, 2 to raise an error and the operation is undone.
  • Message: The attribute which will be displayed in a window (warning or error depending on Severity) if the validation fails.
  • EquipmentCenter: The Equipment Center Instance.
  • LinkType: Equals 1 if the Logical Instance is added, equals 2 if the Logical Instance is removed.
Validation
Variable to set to know if the validation succeeded or failed.

LFS_ValidateAllocationLogicalPortToPCP

This validation rule will be triggered each time a Logical Port is added or removed from the association to the selected PCP.

ThisObject
The Logical Instance of the Logical Port.
Parameters

Standard context:

  • Severity: 1 (default) to raise a warning and the operation can continue, 2 to raise an error and the operation is undone.
  • Message: The attribute which will be displayed in a window (warning or error depending on Severity) if the validation fails.
  • LogicalPort: The Logical Port added or removed.
  • PCPLogicalInstance: The Logical Instance of the PCP.
  • PCP: The PCP.
  • LinkType: Equals 1 if the Logical Port is added, equals 2 if the Logical Port is removed.

Validation
Variable to set to know if the validation succeeded or failed.

LSRRouting_ValidateMultiRoutableObjects

This business rule is triggered at the start of the Manual Route command when more than one logical connection is selected for routing to check that selected connections are valid.

ThisObject
Corresponds to the first logical connection selected.
Parameters

  • Severity: Set to 1 to raise a warning (routing will continue) or to 2 to identify an error (routing is interrupted).
  • Message: Enter the string to be displayed in the warning or error message dialog box.
  • ListOfRoutableObjects: Corresponds to the list of logical connections selected.
Validation
Enter True or False to identify whether or not the validation is successful.

LSRRouting_ValidatePathwaySegment

This business rule is triggered during routing each time a pathway segment is selected to check that the selected segment is valid.

ThisObject
Corresponds to the first pathway segment selected.
Parameters

  • Severity: Set to 1 to raise a warning (routing will continue) or to 2 to identify an error (routing is interrupted).
  • Message: Enter the string to be displayed in the warning or error message dialog box.
  • ListOfRoutableObjects: Corresponds to the list of logical connections selected.
Validation
Enter True or False to identify whether or not the validation is successful.

Example

The following example checks whether or not the pathway segment belongs to the electrical discipline. If not, routing is interrupted and a message issued.

if (ThisObject.Discipline == "Electrical")
  Validation=true 
else
{
  Validation=false 
  Parameters.Severity=2
}
if (Validation <> true)
  Parameters.Message="The pathway segment must belong to the electrical 
  discipline."

LSRRouting_ValidateRoute

This business rule is triggered at the end of the Manual Route command to validate all the pathway segments selected for the route.

ThisObject
Corresponds to the first pathway segment selected.
Parameters

  • Severity: Set to 1 to raise a warning (routing will continue) or to 2 to identify an error (routing is interrupted).
  • Message: Enter the string to be displayed in the warning or error message dialog box.
  • ListOfPathwaySegments: Corresponds to the list of pathway segments selected.
  • ListOfRoutableObjects: Corresponds to the list of logical connections selected.
Validation
Enter True or False to identify whether or not the validation is successful.

Example

The following example calculates the total route length and issues a warning message if the length exceeds 6000mm.

let Length(LENGTH)
let PS(PathwaySegment)
let ListPS(List)

Length = ThisObject.Length

set ListPS = Parameters.GetAttributeObject("ListOfPathwaySegments")

For PS inside ListPS 
		Length = Length + PS.Length

if (Length < 6000mm)	
Validation=true
else
		Validation=false

if (Validation <> true)
  Parameters.Message = "The total route length should be less than 6000mm.
  Here it is " + Length  

LSR_ValidateRouteComponent

This business rule is triggered each time the user tries to select a component other than a Pathway during the Manual Route command.

ThisObject
Corresponds to the selected Logical Component.
Parameters

  • Severity: Set to 1 to raise a warning (routing will continue) or to 2 to identify an error (routing is interrupted).
  • Message: Enter the string to be displayed in the warning or error message dialog box.
Validation
Enter True or False to identify whether or not the validation is successful.

Example

The following example checks whether the selected component is valid as a Route Component depending on the value of the V_Description attribute of its Instance or related reference.

Let listChildren(list)
Let logRef (RFLVPMLogicalReference)

Validation=false
if(ThisObject.V_description == "RouteComponent")
{
    Validation=true
}
else
{
    listChildren= ThisObject.Children
    logRef= listChildren->GetItem(1)

    if ( logRef.V_description == "RouteComponent")
    {
        Validation=true
    }
    else
    {
        Validation=false
    }
}

LSR_GetLengthOfRouteComponent

This business rule is triggered each time the user tries to select another component than a Pathway during the Manual Route command.

ThisObject
Corresponds to the selected Route Component.
Parameters

  • Severity: Set to 1 to raise a warning (routing will continue) or to 2 to identify an error (routing is interrupted).
  • Message: Enter the string to be displayed in the warning or error message dialog box.
  • RouteLength: Corresponds to the length of the route component.
Validation
Variable to set to know if the validation succeeded or failed.

Example

The following example returns a default Routed Length for the selected Route component.

/* CATRule SIGNATURE BEGIN (do not edit) ------------------------------------ */
Let RouteLength_attr      = "RouteLength"
Let RouteLength_val         (Length)               /* In Meters */

/* CATRule SIGNATURE END ---------------------------------------------------- */

/* LOCAL VARIABLES BEGIN ---------------------------------------------------- */
 Let Attr_Length          = "Length"
/* LOCAL VARIABLES END ------------------------------------------------------ */

/* USER ATTRIBUTE VALUES BEGIN ---------------------------------------------- */
/* New Route Component Length */
RouteLength_val           = 0.111m

/* USER ATTRIBUTE VALUES END ------------------------------------------------ */

/* SET VALUES BEGIN --------------------------------------------------------- */

Parameters -> SetAttributeDimension( RouteLength_attr,      RouteLength_val, Attr_Length )

/* SET VALUES END ----------------------------------------------------------- */

LSRRouting_ComputePathwAttrib

This business rule is triggered at the end of the Auto Pathway Routing command to set the pathway attributes. The user will be asked to select a proposed value for the pathway attributes.

ThisObject
Unknown.
Parameters

Rule context:


  • SectionType: Integer.
  • Dimension1: Dimension 1 of the Pathway (Length).
  • Dimension2: Dimension 2 of the Pathway (Length).
  • BendRadiusRatio: BendRadiusRatio of the Pathway.
  • Discipline: Discipline of the Pathway (String)
  • Segregation: Segregation of the Pathway (String)

Example

The following example gives you the list of the Pathway attributes that can be set when Routing them automatically.

Let PathwaySetName_attr = "PathwaySetName"
Let PathwaySetName_val (String)

Let SectionType_attr = "SectionType"
Let SectionType_val (Integer)

Let Dimension1_attr = "Dimension1"
Let Dimension1_val (Length) /* In Meters */

Let Dimension2_attr      = "Dimension2
Let Dimension2_val (Length) /* In Meters */

Let BendRadiusRatio_attr = "BendRadiusRatio"
Let BendRadiusRatio_val (Real)

Let Discipline_attr = "Discipline"
Let Discipline_val (String)

Let Segregation_attr = "Segregation"
Let Segregation_val (String)

/* CATRule SIGNATURE END ---------------------------------------------------- */

/* LOCAL VARIABLES BEGIN ---------------------------------------------------- */
Let Attr_Length = "Length"

let Severity_val (Integer)    /* 0 = OK, 1 = Warning, 2 = Error */
let Message_val (String)      /* Output user defined message */

/* LOCAL VARIABLES END ------------------------------------------------------ */

/*============================================================================*/
/* BUSINESS RULE BEGIN 
/*============================================================================*/

/* USER ATTRIBUTE VALUES BEGIN ---------------------------------------------- */
/*	PathwaySetName_val       = "Pathway100" /* Pathway Set Name */
/*	SectionType_val          =  1     /* 1 = Round, 2 = Rectangular */
/*	Dimension1_val           = .111m  /* Diameter if Round, Height if Rectangular */
/*	Dimension2_val           = .222m  /* Ignored  if Round, Width  if Rectangular */
/*	BendRadiusRatio_val      = .333	/* Bend radius value */
/*	Discipline_val           = "Discipline100" /* Discipline Value */
/*	Segregation_val          = "Segregation100"   /* Segregation Value */
/* USER ATTRIBUTE VALUES END ------------------------------------------------ */

/*============================================================================*/
/* BUSINESS RULE CRITERIA     
/*============================================================================*/

/* USER BUSINESS RULE CRITERIA START (no message display for Severity = 0)------------*/
        Severity_val = 0
        Message_val = ""
/*	if( Dimension1_val == 0m )
        {
            Severity_val = 2
            Message_val = "Dimension Value should not be zero"
        }
        if( Dimension2_val == 0m )
        {
            Severity_val = 2
            Message_val = "Dimension Value should not be zero"
        }
        if( BendRadiusRatio_val == 0 )
        {
            Severity_val = 2
            Message_val = "Dimension Value should not be zero"
        }
*/
/* USER BUSINESS RULE CRITERIA END (no message display for Severity = 0)------------*/
/* SET VALUES BEGIN --------------------------------------------------------- */

/*	Parameters -> SetAttributeString   ( PathwaySetName_attr,  PathwaySetName_val )
   Parameters -> SetAttributeInteger  ( SectionType_attr,     SectionType_val )
   Parameters -> SetAttributeDimension( Dimension1_attr,      Dimension1_val, Attr_Length )
   Parameters -> SetAttributeDimension( Dimension2_attr,      Dimension2_val, Attr_Length )
   Parameters -> SetAttributeReal     ( BendRadiusRatio_attr, BendRadiusRatio_val )
   Parameters -> SetAttributeString   ( Discipline_attr,      Discipline_val )
   Parameters -> SetAttributeString   ( Segregation_attr,     Segregation_val )
*/
/* SET VALUES END ----------------------------------------------------------- */

/* SET OUTPUT BEGIN --------------------------------------------------------- */
   Parameters.Severity = Severity_val
   Parameters.Message  = Message_val
/* SET OUTPUT END ----------------------------------------------------------- */

L3m_BR_ValidatePosition

This validation rule will be triggered each time a 3d Space reservation is added to a logical Instance or moved.

ThisObject
Logical Instance Space Reservation is associated to.
Parameters

Instance Context (Context XYZ is relative to).

XYZ location (relative to instance Context).

Severity Parameter

  • Severity: 1 (default) to raise a warning and the operation can continue, 2 to raise an error and the operation is undone
  • Message: attribute which will be displayed in a window (warning or error depending on Severity) if the validation fails.

L3m_BR_ValidatePathwayConnect

The validation rule will be triggered each time a Pathway is trying to get connected or disconnected from either another Pathway or a Logical Extremity.

ThisObject
Pathway Instance.
Parameters
Object1 to Connect/Disconnect (PathwaySegment or Logical Instance).
Object2 to Connect/Disconnect (PathwaySegment or PathwayConnectionPoint)
Severity Parameter

  • Severity: 1 (default) to raise a warning and the operation can continue, 2 to raise an error and the operation is undone.
  • Message: attribute which will be displayed in a panel (warning or error depending on Severity) if the validation fails.

L3m_BR_ComputePathwayAttr

This validation rule is triggered each time you create a pathway using the Create Pathway command or the Auto Pathway Routing command. The values in this rule define the default parameters of the new pathways.

ThisObject
PathwaySet Instance instance (a PathwaySet is a logical object containing 1 or more Pathways).
Parameters (In / Out)

  • PathwaySet Name (String)
  • Section Type (integer): 1 > Round, 2 > Rectangular.
  • Dimension1 (CKE): Diameter if Round, Height if Rectangular.
  • Dimension2 (CKE): Ignored if Round, Width if Rectangular.
  • Bend Radius Ratio (Double)
  • Offset Mode (Integer): 1 > Bottom, 2 > Center
  • Offset Value (CKE)
  • Discipline (String)
  • Segregation (String)
  • CurveMethod (String): Straightbend, Corneredpolyline

PLMBusinessLogic_Logical_BLInstanceInitialization.CATRule

This rule is triggered during the creation of an object.

The values in this rule define the default names of the new object.

ThisObject

The PLM instance being created and named.

Parameters

  • OperationId : String defining how the object is being created (example: New).
  • OperationDetail : String defining the way the object is being created (example: Create).
  • CustoType : String by which UniqueKey ID is generated.
  • Reference : PLM entity (the new object reference which is being created).
  • AggregatingReference : PLM entity (the father object under which the new object is created).

Example

Note: You can modify and copy relevant segments of this example to your own rules, as required.

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

Let CustoType=""
Let UniqueKey=""
Let strTypediscipline=""
Let TName=""
Let Reference(PLMEntity)
Let AggReference(PLMEntity)
Let Operation(string)
Let OperationDetail(string)
Let CoupledRefId(string)
Let CoupledRef(PLMProductDS)
Let OriDesc(string)
Let CopyFrom(PLMProductDS)
Let CopyFromId(string)
Let CloningString(string)
Let PrimaryType(Type)
Let RepInstance(RFLVPMLogicalRepInstance)
Let Instance(RFLVPMLogicalInstance)

/*--------------------------------------------------------------------------*/
Operation=Parameters->GetAttributeString("OperationId")
OperationDetail = Parameters->GetAttributeString("OperationDetail")
CustoType = Parameters->GetAttributeString("CustoType")

If(Operation=="New" or Operation=="Implicit" or Operation=="Default")
{
	Trace(1,"CATRule_Sample_for:Operation==New or Operation==Implicit or Operation==Default")
	UniqueKey = GetUniqueKey(CustoType)	
	set Reference = Parameters->GetAttributeObject("Reference")
	set strTypediscipline  = Reference.V_discipline
	/* Creation of Rep instances  as V_discipline is empty */
	if( strTypediscipline  == "" )   
	{
		If (Parameters->HasAttribute("CoupledRef") == true)
		{
			 if (OperationDetail == "Create")
			{
				set AggReference = Parameters->GetAttributeObject("AggregatingReference")			
				set strTypediscipline  = AggReference.V_discipline
				
				if(strTypediscipline == "EquipmentCenter")
				{			
					/*Customized naming*/
					ThisObject.PLM_ExternalID = "EC3_EquipmentCenter_Representation_instance_" + UniqueKey
				}
				else if(strTypediscipline == "RequirementVolume")
				{
					/* Customized naming */
					ThisObject.PLM_ExternalID = "EC3_Zone_Representation_instance_" + UniqueKey
				}
				else if(strTypediscipline == "PathwaySet")
				{
					/* Customized naming */
					ThisObject.PLM_ExternalID = "EC3_Pathway_Representation_instance_" + UniqueKey
				}
				else if(strTypediscipline == "Space_Allocation")
				{
					/* Customized naming */
					ThisObject.PLM_ExternalID = "EC3_Space_Allocation_Representation_instance_" + UniqueKey
				}
				else
				{
					set PrimaryType = ThisObject.PrimaryType
					TName = PrimaryType.Name
					if ( "RFLVPMLogicalInstance" == TName )
					{
						ThisObject.PLM_ExternalID = "EC3_Equipment_instance_" + UniqueKey
					}
					else if ( "RFLVPMLogicalRepInstance" == TName )
					{
						ThisObject.PLM_ExternalID = "EC3_Equipment_Representation_instance_" + UniqueKey
					}				
				}
			}
		}
	}
	else
	{
		/* Creation of instances  */
		if (OperationDetail == "Create")
		{
			if(strTypediscipline == "EquipmentCenter")
			{			
				/*Customized naming*/
				ThisObject.PLM_ExternalID = "EC3_EquipmentCenter_instance_" + UniqueKey
			}
			else if(strTypediscipline == "RequirementVolume")
			{
				/* Customized naming */
				ThisObject.PLM_ExternalID = "EC3_Zone_instance" + UniqueKey
			}
			else if(strTypediscipline == "PathwaySet")
			{
				/* Customized naming */
				ThisObject.PLM_ExternalID = "EC3_Pathway_instance" + UniqueKey
			}
			else if(strTypediscipline == "Space_Allocation")
			{
				/* Customized naming */
				ThisObject.PLM_ExternalID = "EC3_Space_Allocation_instance" + UniqueKey
			}
			else
			{
				/* Customized naming */
				ThisObject.PLM_ExternalID = "EC3_Equipment_instance" + UniqueKey
			}		
		}		
	}
}
/*--------------------------------------------------------------------------
if (OperationDetail == "CopyPaste")
{
	/// Case of cloning 
	if ((Operation=="Implicit") or (Operation=="Cloning"))
	{
		UniqueKey = GetUniqueKey(CustoType)
		set Reference = Parameters->GetAttributeObject("Reference")
		ThisObject.PLM_ExternalID = Reference.PLM_ExternalID + "." + UniqueKey
	}
}
/////Management of coupling between Representation Reference Naming and Part Reference naming
If (Parameters->HasAttribute("CoupledRef") == true)
{
	set CoupledRef = Parameters->GetAttributeObject("CoupledRef")
	/// Test if a coupled Part Reference exists
	if(CoupledRef <> NULL)
	{
		/// Retrieve the Attributes on the couple Part Reference
		CoupledRefId = CoupledRef->GetAttributeString("PLM_ExternalID")
		ThisObject.PLM_ExternalID = "3DRep of "+CoupledRefId
		ThisObject.V_description = "Representation for part "+CoupledRefId
	}
	else
	{
		/// Default naming based on a customized numbering
		Prefix = Parameters->GetAttributeString("IdString")
		ThisObject.PLM_ExternalID = Prefix +"Representation"	
	}
}
--------------------------------------------------------------------------*/