View Full Version : How to find 0 length piperuns in SPPID 4.3
Trying to find the endpoint x/y's of the piperun. Anyone have any ideas?
This function is to judge 0 length of piperun.
I use this function to delete 0 length piperun from Excel piperun list as post-processing.
Function CheckZeroLength(objpiperun As LMPipeRun) As Boolean
Dim Representation As LMRepresentation
Dim connectorZero As LMConnector
Dim blZeroLength As Boolean
'Exclude zero length connector
For Each Representation In objpiperun.Representations
If Representation.Attributes("RepresentationType") = "Connector" Then
Set connectorZero = LMADS.GetConnector(Representation.ID)
blIsZeroLength = connectorZero.Attributes("IsZeroLength").Value
If blIsZeroLength = False Then
Exit For
End If
End If
Next
CheckZeroLength = blIsZeroLength
End Function
For Each Representation In objpiperun.Representations
If Representation.Attributes("RepresentationType") = "Connector" Then
Set connectorZero = LMADS.GetConnector(Representation.ID)
blIsZeroLength = connectorZero.Attributes("IsZeroLength").Value
If blIsZeroLength = False Thenwow, the way I was thinking was 10x more complex than this. I will be quite pleased if this works for me. So you loop through each piperun representation. You get the ID of the representation (didn't know you could use LMADS instead of LMAdatasource, nice) then you set the zeroLength to true or false.
How do you know if the piperun is zero length or not just by getting the ID of its representation? Keep in mind I am working in 4.3 at the moment not 2007. The way I made it work today was to find the x and y of both sides of the piperun (x1, x2, y1, y2) round them down to 4 decimal places (so .3456 instead of .34558900000) and then compare them. If they were the same x1 and x2 - y1 and y2, I could flag it. I get stuck sometimes negotiating through the connectors and symbols to find the model item I am looking for. Thanks Tim. Glad to have another SP admin here.
Connector has an attribute named "IsZeroLength".
Zero length piperun is automatically created when you place instrument to nozzle to maintain connectivity. And such piperun's connector has "True" value of "IsZeroLength".
This function will work with v4.3(2007 too).
Hope this will help you.
Thanks Tim. There is no IsZeroLength field in the piperun table in 4.3 - thus the work around (out of the box).
so I may have spoken too soon here. Even though I never dim'd iszerolength as a bool, i typed it in and it was formatted for me. Is this a hidden function?
dave,
It's not piperun that has attribute IsZeroLength but connector.
This attribute is default field that system will automatically set.
you don't have to add it manually.
Tim in the connector table, I see the IsZeroLength field - thanks. Does 1 mean "False" and 2 mean "True"?
So I finally get to use this. Thanks Tim - extremely helpful.
tim. What I've done is created a new field called myzerolength and when a piperun isZeroLength, myzerolength is set to "true" - then I have a display set in the drawings to show piperuns with myzerolength set to true.
Obviously this doesn't quite work out as the zerolength piperuns themselves have the same SPPID as their non zero length partners. I assume there isn't a way to differentiate between zero length and non zero length with the same SPPID in 4.3?
dave
What do you mean by this?
"the zerolength piperuns themselves have the same SPPID as their non zero length partners"
each piperun object has unique SP_ID.
I didn't think that your final purpose is to highlight zero length piperuns by displayset.
I use my VB code to delete meaningless zero length records from Excel piperun report.
What do you want to do with that?
These zero length piperun is required to maintain connectivity, you should not delete these zero length piperuns.
no, the final purpose was to identify if a nozzle was connected to a zero length piperun and then to find what it was connected to and then do some operations which I have accomplished.
This last task just came in. The project people want a display set to see all 0 length piperuns for some reason. Honestly I don't remember why.
For example; if you have "equipment-->nozzle-->0 length-->valve-->piperun"
Unless I'm mistaken the 0 length will have the same SPID as the piperun and therefore inherit the myzerolength value.
no I am not deleting the 0 length piperuns :)
dave
"equipment-->nozzle-->0 length-->valve-->piperun"
In this case, there's only one piperun in the datasource, piperun will not divided by inserting on-line component (ex. valve). Even if operator place piperun from one end of on-line component, system will automatically merge the piperun with opposite side piperun as one piperun.
You can use IsZeroLength property of connector.
If a piperun has a connector with IsZeroLength true, that means the piperun has zero length part.
If a piperun has a connector with IsZeroLength true, that means the piperun has zero length part.
correct but since that 0 length part doesn't always have a unique SPPID, I cannot create a display set for 0 length piperuns only. B)
dave
You can judge it by counting connectors. If the number of connector is 2 and have attribute IsZerolength true, that is real 0 length piperun.
Try to set your dummy attribute myZerolength based on this criteria and create displayset.
tim, how do I prevent the myzerolength value from propigating to the non zero length piperun? Should I make a rule?
here's the code so far...
Dim pipe As LMPipeRun
Dim pipes As LMPipeRuns
Dim eqp As LMEquipment
Dim pipecomp As LMPipingComp
Dim noz As LMNozzle
Dim nozs As LMNozzles
Dim drawing As LMDrawing
Set pipes = New LMPipeRuns
Dim plantitem As LMPlantItem
pipes.Collect objdatasource, Filter:=objFilter
Dim Representation As LMRepresentation
Dim connectorZero As LMConnector
Dim connectors As LMConnectors
Dim blZeroLength As Boolean
Dim i As Integer
i = 0
For Each pipe In pipes
'Exclude zero length connector
For Each Representation In pipe.Representations
If Representation.Attributes("RepresentationType") = "Connector" Then
Set connectorZero = objdatasource.GetConnector(Representation.ID)
Set drawing = connectorZero.DrawingObject
'Debug.Print drawing.Attributes("Name").Value
'If drawing.Attributes("Name").Value = "ToFromTest" Then
blIsZeroLength = connectorZero.Attributes("IsZeroLength").Value
If blIsZeroLength = True Then
objdatasource.BeginTransaction
Debug.Print pipe.Attributes("itemtag")
pipe.Attributes("myzerolength").Value = "true"
pipe.Commit
objdatasource.CommitTransaction
i = i + 1
Exit For
'End If
End If
End If
Next
Next
MsgBox "done with " & i & " changes"
End Sub
here is a sample. (not tested)
I don't know how to quote VB code in this post.
For Each pipe In pipes
connectcount = 0
blIsZeroLength = False
For Each Representation In pipe.Representations
If Representation.Attributes("RepresentationType") = "Connector" Then
connectcount = connectcount + 1
Set connectorZero = objdatasource.GetConnector(Representation.ID)
Set Drawing = connectorZero.DrawingObject
If connectorZero.Attributes("IsZeroLength").Value Then
blIsZeroLength = True
End If
End If
Next
objdatasource.BeginTransaction
If blIsZeroLength = True And connectcount = 2 Then
pipe.Attributes("myzerolength").Value = "true"
i = i + 1
Else
pipe.Attributes("myzerolength").Value = "false"
End If
pipe.Commit
objdatasource.CommitTransaction
Next
awesome Tim thanks. I will check it out tomorrow. To put your code in code tags, simply enclose it in [ code ] YOUR CODE HERE [ /code ] tags (without the space in between the [ and code).
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.