Sunday, February 15, 2009

Raising a Pipe Run

Sometimes it's interesting, to me at least, where this blog site is linked from. Recently I saw a link coming from, which is the "largest and most active German-speaking community for CAD-CAM-CAE and EDM / PDM / PLM and other interested users on the Internet." It also hosts the AUGCE message board. The question one user had was how to raise (or lower) a run of pipes based on the ending invert elevation. In the list of options on how to accomplish the task was a link to the Pipe Slope Along a Run post and creating your own program to do it.

This post will take the post referenced and modifying it to raise the pipe run a set amount. It won't affect any branch runs, so you will have to adjust them by running the command again. If you want to follow along download the previous code at this link. Type VBALOAD at the command line to load the file and VBAIDE to open the Visual Basic Editor, enable Macros if it asks. Next create a new module and name it PipeAdjustRun (you can do that in the Properties Window).


Next copy the code from the Sub PipeSlopeRun and paste it into the new module, adding Option Explicit to the top of the code and renaming the sub PipeAdjustRun.


Next change the dSlope to something that makes more sense for this code, such as dElevDiff. Do a find and replace for the current module and it will change all of the instances of dSlope to dElevDiff.

We want the code to work in the same manner so most of the code will remain the same, but we do want the user to tell us what elevation difference they want to apply. So change the user prompt to ask for the elevation change.


Now the math portion of the code needs to be revised to adjust the pipe's elevation values. The portion of code that needs to be revised is shown below:


And the revised code is shown below:


And that should raise or lower a selected pipe run a specific amount. This code revisions comes with the usual disclaimers, not a whole lot of error checking has been done, check the program to make sure it is working as you expect and if you want some basic error catching add On Error Resume Next at the top of Sub, otherwise an error message will pop. You may have noticed I added the modified code at this link to save you some typing.

1 comment:

Anonymous said...

I like this example and am looking at this in a bit more depth. The above example works if all the pipe sizes are equal.

As we mostly use either invert to invert or crown to crown design where a pipe changes in size only the centreline will be correct. The top and bottom of the pipes will not match.

For crown to crown design the text would be:

Dim dlastLevel As Double
Dim dPipe1Dia As Double
bFirst = True

For i = 0 To UBound(oPathArray)
If (TypeOf oPathArray(i) Is AeccPipe) Then
Set oPipe = oPathArray(i)
If bFirst = True Then
dElev = oPipe.StartPoint.Z
dlastLevel = dElev
dPipe1Dia = oPipe.InnerDiameterOrWidth
bFirst = False
End If
oPipe.StartPoint.Z = (dElev + (dPipe1Dia / 2)) - (oPipe.InnerDiameterOrWidth / 2)
oPipe.EndPoint.Z = dElev + (oPipe.Length2D * dSlope)
dElev = oPipe.EndPoint.Z
dlastLevel = dElev
dPipe1Dia = oPipe.InnerDiameterOrWidth
End If

This looks at the first pipe logs the diameter then and works out the difference between each one.
For invert to invert design change to the following
"dElev - (dPipe1Dia / 2)) + (oPipe.InnerDiameterOrWidth / 2)" basically swapping the plus and minus.

Thanks for this one, it's a huge help. I just need to work out how to enter 1:x gradients and how to tell it to use invert or crowns next : )


Blog Widget by LinkWithin