Context:
Type : 2 Checks
Purpose : Check if the number of clamp along the pipe is enough & check if the maximum distance is respected
Code example
Check if there is enough clamp along the pipe
/* Argument : PipeOcc , Piping_Pipe_Occurence */ Let PipeRef (Piping_Pipe) //pipe reference let PipeLength (length) // pipe length Let PartOcc (Piping_Part_Occurrence) // Piping Part occurence attached to the pipe let PartRef (Piping_PartV1) // Piping Part Reference let PartSubType(String) // Piping Part PartSubType let PartList (List) // list of Part attached to the pipe let NbPartList(Integer) // Nb of part in the PartList let ClampList (List) // subset of PartList with only Clamp type let NbClampList (Integer) // Nb of Clamp in the Clamp List let MaxClampDistance (LENGTH) // Inputs - Max distance between Clamp to be respected let MinNbOfClampNeeded (Real) let FinalMessage(String) //final message for the Check Let i (integer) //counter used for loop let j (Integer) //counter for List rank Let CheckStatus (string) // initialize values Set MaxClampDistance =300mm FinalMessage="" CheckStatus="OK" i=1 j=1 // Retreive Pipe reference informations - length PipeRef=PipeOcc.Reference set PipeLength = PipeRef.V_Length //Retreive Parts list connected to Pipe set PartList=PipeOcc.GetRelatedObjects() NbPartList = PartList.Size() Notify ( "NbPartList:", NbPartList) //create a new list that contains only PipingPart with subtype =Clamp for i while i <= NbPartList { set PartOcc = PartList.GetItem(i) PartRef=PartOcc.Reference set PartSubType = PartRef.GetAttributeString("V_SubPartType") if PartSubType=="Clamp" { ClampList->AddItem(PartOcc,j) j=j+1 } } NbClampList = ClampList.Size() set MinNbOfClampNeeded=PipeLength/MaxClampDistance Notify ("PipeLength: ", PipeLength) Notify ( "NbClampList:", NbClampList) Notify("MaxClampDistance: ",MaxClampDistance) Notify ("MinNbOfClampNeeded: ", MinNbOfClampNeeded) If (NbClampListAddTupleSucceededWithComment(FinalMessage,PipeOcc) Notify ("Final Message OK : " + FinalMessage) } else { ThisCheck->AddTupleFailedWithComment(FinalMessage,PipeOcc) Notify ("Final Message KO : " + FinalMessage) }
Check distance between clamp along the pipe < max length
/* Argument : PipeOcc , Piping_Pipe_Occurence */ Let PipeRef (Piping_Pipe) //pipe reference let PipeLength (length) // pipe length Let PartOcc (Piping_Part_Occurrence) // Piping Part occurence attached to the pipe let PartRef (Piping_PartV1) // Piping Part Reference let PartSubType(String) // Piping Part PartSubType Let Clamp1Occ (Piping_Part_Occurrence) // Clamp1 occurence attached to the pipe Let Clamp2Occ (Piping_Part_Occurrence) // next Clamp2 occurence attached to the pipe let Clamp1Inst (Piping_Part_Inst) // Clamp1 instance attached to the pipe let Clamp2Inst (Piping_Part_Inst) // Next Clamp2 instance attached to the pipe let PartList (List) // list of Part attached to the pipe let NbPartList(Integer) // Nb of part in the PartList let ClampList (List) // subset of PartList with only Clamp type let NbClampList (Integer) // Nb of Clamp in the Clamp List let M1 (Matrix) // position matrix of Clamp1 - LocalPosition let M2 (Matrix) // position matrix of next Clamp2 - LocalPosition let T1 (Vector) // translation Vector of Clamp1 - LocalPosition let T2 (Vector) // translation Vector of Clamp2- LocalPosition let T (Vector) // vector between Clamp1 and Clamp2 let TNorm (Real) // Norme de T : distance between Clamp1 and clamp2 let ClampDist (Length) // Distance between 2 consecutive Clamps let ClampDistList (List) // List of Clamp distance let NbClampDistList(Integer) //Nb clamp interval let MaxClampDistance (LENGTH) // Inputs - Max distance between Clamp to be respected let ClampDistListKO (List) // output - list of distance tant doesn't respect the Max value let TextKO (String) // text for the distance that doesn't respect the Max value let MessageKO (String) // final text for ALL distance that doesn't respect the max value let FinalMessage(String) //final message for the Check Let i (integer) //counter used for loop let j (Integer) //counter for List rank let ClampInterval (Integer) //count of Clamp interval let ClampIntervalKO (Integer) //count for Clamp interval that doesn't respect Max distance Let CheckStatus (string) // initialize values Set MaxClampDistance =300mm TextKO="" MessageKO="" FinalMessage="" CheckStatus="OK" i=1 j=1 ClampInterval=0 ClampIntervalKO=0 // Retreive Pipe reference informations - length PipeRef=PipeOcc.Reference set PipeLength = PipeRef.V_Length //Retreive Parts list connected to Pipe set PartList=PipeOcc.GetRelatedObjects() NbPartList = PartList.Size() Notify ( "NbPartList:", NbPartList) //create a new list that contains only PipingPart with subtype =Clamp for i while i <= NbPartList { set PartOcc = PartList.GetItem(i) PartRef=PartOcc.Reference set PartSubType = PartRef.GetAttributeString("V_SubPartType") if PartSubType=="Clamp" { ClampList->AddItem(PartOcc,j) j=j+1 } } NbClampList = ClampList.Size() Notify ( "NbClampList:", NbClampList) // if there is 0 or only one Clamp check is OK if NbClampList==0 { if PipeLength<=MaxClampDistance { CheckStatus="OK" FinalMessage="OK , no Clamp & pipe length<=" + MaxClampDistance } else { CheckStatus="KO" FinalMessage="KO : Clamp missing : No Clamp & pipe length>" + MaxClampDistance } } else if NbClampList==1 { if PipeLength<=MaxClampDistance*2 { CheckStatus="OK" FinalMessage="OK : only one Clamp & pipe length<= 2x" + MaxClampDistance } else { CheckStatus="KO" FinalMessage="KO : One Clamp & pipe length> 2x" + MaxClampDistance } } else { // Create list of Distances between 2 consecutive clamps rang i & j i=1 ClampInterval=1 for i while i <= (NbClampList-1) { set Clamp1Occ = ClampList.GetItem(i) j=i+1 set Clamp2Occ = ClampList.GetItem(j) Clamp1Inst = Clamp1Occ.Instance Clamp2Inst = Clamp2Occ.Instance // Retrive Clamp instance Matrix for 2 consecutive Clamp M1 = Clamp1Inst.PositionMatrix M2 = Clamp2Inst.PositionMatrix // Extract the 4th column to read the translation vector of the position matrix for the 2 clamps T1=M1.GetColumn( 4 ) T2=M2.GetColumn( 4 ) Notify( "T1=", T1.Dump() ) Notify( "T2=", T2.Dump() ) //compute Vector T between 2 clamps, compute distance = norm de T , set distance in mm set T=T2-T1 Notify( "T=", T.Dump() ) TNorm=T->Norm() Notify("TNorm =", TNorm) ClampDist=TNorm*1mm Notify("distances = ", ClampDist) //store distance in list ClampDistList->AddItem(ClampDist,ClampInterval) ClampInterval=ClampInterval+1 // KO distance in a list if ClampDist>MaxClampDistance { CheckStatus="KO" ClampIntervalKO=ClampIntervalKO+1 ClampDistListKO->AddItem(ClampDist,ClampIntervalKO) TextKO="KO - Dist Clamp" + i + "To" + j + "=" + ClampDist + ">" + MaxClampDistance + " ; " } Notify("Nb of intervalKO=",ClampIntervalKO) Notify("TextKO: "+ TextKO) FinalMessage=FinalMessage + TextKO Notify("FinalMessage: " + FinalMessage) } } If (CheckStatus=="OK") { ThisCheck->AddTupleSucceededWithComment(FinalMessage,PipeOcc) Notify ("Final Message: " + FinalMessage) } else { ThisCheck->AddTupleFailedWithComment(FinalMessage,PipeOcc) Notify ("Final Message: " + FinalMessage) }
If your clamp are not "Piping part" but "SharedSupport" type :
in the above rules the Clamp is supposed to be a Piping Part Occurence
IF you are using "Support" Object type for Clamp then you must define in the rule the Clamp object as a "SharedSupportPartOccurrence"
--> the above rule must be adjust :
Warning : Today 23x-24xGA this code doesn't work because the function to get Object form PipeOcc "GetRelatedObjects()" doesn't return the "SharedSupportPart" object type --> need to investigate on how to retreive "SharedSupportPartOccurence" from Pipe Occurence
Current code for Piping Part Occ
//create a new list that contains only PipingPart with subtype =Clamp for i while i <= NbPartList { set PartOcc = PartList.GetItem(i) PartRef=PartOcc.Reference set PartSubType = PartRef.GetAttributeString("V_SubPartType") if PartSubType=="Clamp" { ClampList->AddItem(PartOcc,j) j=j+1 } } To be replaced by following : First , declare the variable for "Support" Let SupportOcc (SharedSupportPartOccurrence) // Support occurence attached to the pipe create the list of support per pipe //create a new list that contains only Support object type for i while i <= NbPartList { set SupportOcc = PartList.GetItem(i) ClampList->AddItem(SupportOcc,j) j=j+1 }