EKL - RFLP propagate infromation through Implement link

Exemple1 : Update P&ID LineID member attribute from a Requirement specification

SUMMARY: 

Here's a script allowing to, by selecting a logical instance referring to a line ID, to update all members of this line ID from the requirement specification it is linked to.

The script, from the selected pipe instance, finds its line ID. Then it goes through every implement link starting from this line ID's reference and if the object is a requirement specification, it will go through every requirement and parameter contained in the requirement specification and set it on the line ID's reference, or compute the adequate value depending on the need.

Then, it will force the attribute values from the line ID's reference to all the logical instances referring to our line ID.

 

RECORDING

 

SCRIPT SAMPLE


 

 

Rule

//Argument(name: Selection ; type: LogicalOccurrence)

Let LogPipLineOcc, LogPartOcc (LogicalOccurrence)
Let LogPipLineRef (RFLVPMLogicalReference)
Let LogPartInst (RFLVPMLogicalInstance)
Let LstLineID, LstLogPipLine, LstImpOnPipLine, LstIntImpOnPipLine, LstReqFromSpec, LstParamFromReq, LstParamFromReqName, LstImplLink, LstLineIDMembers (List)
Let ReqSpecFt (Feature)
Let ReqSpec (`Requirement Specification`)
Let ReqFromSpec (Requirement)
Let i, j, k, l (Integer)
Let ParamFromReq (PlmParameter)
Let ParamFromReqName, TempParamFromReqName, ParamFromLineIDName, NSize, NSize2, OpPres (String)
Let Temp (TEMPRTRE)
Let Pres (PRESSURE)

//Get the list of Line ID's connected to Selection (Should be of size 1)
ListLogicalLineFromMember(Selection, LstLineID)
Notify("LstLineID.Size() = ", LstLineID.Size())

//Get the Line ID occ from the list
LogPipLineOcc=LstLineID.GetItem(1)

//Get the Line ID Ref from Occ
Set LogPipLineRef=LogPipLineOcc.Reference
Notify("LogPipLineRef.name = ", LogPipLineRef.name)

//Put the Line ID back into a list
LstLogPipLine.Append(LogPipLineRef)

//Get the list of list of features that the Line ID is connected to via Implement. links
LstIntImpOnPipLine = GetImplemented(LstLogPipLine, LstImplLink)
//Get the list of features that the Line ID is connected to via Implement. links from the previous list
LstImpOnPipLine = LstIntImpOnPipLine.GetItem(1)
//Size of the implement links list
Notify("LstImplLink.Size() = ", LstImplLink.Size())
//Name of the implement links list
Notify("LstImplLink.name = ", LstImplLink.GetItem(1).Name())
//Size of the implemented objects list
Notify("LstImpOnPipLine.Size() = ", LstImpOnPipLine.Size())
//Name of the implemented objects list
Notify("LstImpOnPipLine.name = ", LstImpOnPipLine.GetItem(1).Name())

//Loop on each feature connected to Line ID
For i=1 while i<=LstImpOnPipLine.Size() {
    
    //Get the corresponding feature from the list
    ReqSpecFt=LstImpOnPipLine.GetItem(i)
    
    Notify("ReqSpecFt.Name = ", ReqSpecFt.Name)
    Notify("ReqSpecFt.IsSupportingRequirement Specification = ", ReqSpecFt.IsSupporting("Requirement Specification") or ReqSpecFt.IsASortOf("Requirement Specification"))
    
    //Check if the feature is a Requirement Specification
    If ReqSpecFt.IsSupporting("Requirement Specification") or ReqSpecFt.IsASortOf("Requirement Specification"){
        //Force the Requirement Specification into its type
        set ReqSpec=ReqSpecFt
        //Get the list of Requirements from the requirement Specification
        LstReqFromSpec=ReqSpec.GetReqChildren()
        
        Notify("LstReqFromSpec.Size() = ", LstReqFromSpec.Size())
        
        //Loop on each of those Requirements
        for j=1 while j<=LstReqFromSpec.Size() {
            //Get the corresponding Requirement from the Requirement Specification
            ReqFromSpec=LstReqFromSpec.GetItem(j)
            //Get the Parameters located under the Requirement
            LstParamFromReq=ReqFromSpec.GetPLMParameters()
            
            Notify("LstParamFromReq.Size() = ", LstParamFromReq.Size())
            
            //Loop on each of those Parameters
            for k=1 while k<=LstParamFromReq.Size(){
                //Get the corresponding Parameter from the Requirement
                ParamFromReq=LstParamFromReq.GetItem(k)
                //Check if the parameter is a temperature
                
                //Get the parameter name
                ParamFromReqName=ParamFromReq.Name
                
                //Format the parameter name into the Line ID's attribute name
                //Separate each part of the name separated by " "
                LstParamFromReqName=SplitString(ParamFromReqName, " ", false)
                //Start with the "V_" prefix
                Set ParamFromLineIDName="V_"                
                //Loop on every substring                
                For TempParamFromReqName inside LstParamFromReqName {
                    //Add it to "V_"
                    ParamFromReqName=ParamFromReqName+TempParamFromReqName
                }
                Notify("ParamFromReqName = ",ParamFromReqName)
                
                If ParamFromReq.PlmParamType=="TEMPRTRE" {
                    //Turn the parameter into Kelvin
                    Temp=ParamFromReq.PlmParamRealValue*1Kdeg
                    //Print the temperature
                    Notify("Temp = ", Temp)
                }
                
                //Check if the parameters is a pressure                
                Else if ParamFromReq.PlmParamType=="PRESSURE" {

                    //Pres=ParamFromReq.PlmParamRealValue*1psi
                    Pres=ParamFromReq.PlmParamRealValue
                    //Print the pressure
                    Notify("Pres = ", Pres)
                    
                    //Define the nominal diameter depending on the operating pressure
                    //from 1 to 300psi : DN80
                    If Pres>1psi and Pres<=300psi
                        NSize="DN80"
                    //from 300 to 600 psi: DN100
                    Else If Pres>300psi and Pres<=600psi
                        NSize="DN100"
                    //from 600 to 900 psi: DN125
                    Else If Pres>600psi and Pres<=900psi
                        NSize="DN125"
                    //from 900 to 1800 psi: DN300
                    Else If Pres>900psi and Pres<=1800psi
                        NSize="DN300"
                    
                    //Set the Reference Line ID pressure according to the requirement
                    LogPipLineRef.SetAttributeReal("V_OperatingPressure", Pres)
                    Notify("V_OperatingPressure = ", Pres)
                    
                    //Set the Reference Line ID nominal size according to the requirement
                    LogPipLineRef.SetAttributeString("V_NominalSize", NSize)
                    Notify("V_NominalSize = ", NSize)
                    
                    //Get all members related to the original Line ID
                    LstLineIDMembers = ListPipingLineIDMembers(LogPipLineOcc)

                    //Loop on all Line ID members
                    for l = 1 while l<= LstLineIDMembers.Size(){
    
                        //Get Line ID member
                        set LogPartOcc = LstLineIDMembers.GetItem(l)
    
                        //Get the corresponding logical part instance
                        set LogPartInst = LogPartOcc.Instance
    
                        //Set the rigth nominal size on the instance
                        LogPartInst.SetAttributeString("V_NominalSize", NSize)
                        
                    }                                        
                }
            }
        }
    }
}