Have you ever started laying out a pipe network using the cover and slope pipe rule or Pipe Cover and found the pipes down near the zero elevation? Well if your like me you don’t really appreciate having the pipes down at the zero elevation. Here’s a way to change the rule to put the elevation at a place which would be more desirable without having to move the pipes later on.
NOTE: Before you start make sure you save a copy of the C3DPipeRules.dvb to another location to easily go back to the original state.
To do this open up the Visual Basic Editor after you have worked with a pipe (working with a pipe should load the C3DPipeRules.dvb file automatically). This post has more information on how to load Visual Basic files. Go to the CoverAndSlope Module and scroll down to the Public Sub ApplyWithoutSurface routine, to the part that is below:
1 ‘ If the last elevation is equal to our double max,
2 ‘ then the last elevation has not been set in the network state
3 ‘ and we will set the starting elevation to the minimum cover
4 ‘
5 If dLastElevation = c_DBL_MAX Then
6 dNewPipeZ = 0
7 If eFlowDir = aeccPipeFlowDirectionStartToEnd Then
8 dNewPipeZ = dNewPipeZ – dMinimumCover
9 oPipe.StartPoint.Z = (dNewPipeZ – oPipe.OuterDiameterOrWidth * 0.5)
10
11 ElseIf eFlowDir = aeccPipeFlowDirectionEndToStart Then
12 dNewPipeZ = dNewPipeZ – dMinimumCover
13 oPipe.EndPoint.Z = (dNewPipeZ – oPipe.OuterDiameterOrWidth * 0.5)
14 End If
15 ‘ otherwise set the starting elevation to the last elevation
16 ‘
17 Else
18
19 If eFlowDir = aeccPipeFlowDirectionStartToEnd Then
20 oPipe.StartPoint.Z = dLastElevation
21 ElseIf eFlowDir = aeccPipeFlowDirectionEndToStart Then
22 oPipe.EndPoint.Z = dLastElevation
23 End If
24 End If
You can change the dNewPipeZ = 0 (Line 5), to a new value or we can change it to prompt the user for the elevation they want to use. The new line could be the following:
dNewPipeZ = ThisDrawing.Utility.GetReal(vbCrLf & “Surface not found, enter invert elevation to use:”)
If you then create a pipe network you will see that we have two problems with the change of prompting the user for the invert elevation. The first is the invert elevation of the first pipe is not the same as the one we entered into the program and the second is that it asks you again to enter the invert elevation at the end of laying out the network.
The first problem is explained in the code shown above, it is setting the starting elevation to the minimum cover as told in the programming notes. To correct this remove lines 8 and 13 from the code above and change the negative sign and the word outer in lines 9 & 14 to a positive and Inner. I suggest using a ‘ before the line to remove it and adding a note to explain why you did the change so you can easily go back at a future date and reverse the revision. The oPipe.Endpoint.Z and oPipe.StartPoint.Z refer to the center of the pipe.
The next change we have to make is to get the program to not ask you what the invert elevation is the second time. To accomplish this we are going to add an If Then statement around where it is setting the starting elevation. So right after line 5 add:
If oPipe.StartPoint.Z = 0 Then
After line 16 put End If. So the finished code should look something like this:
1: ‘ If the last elevation is equal to our double max,
2: ‘ then the last elevation has not been set in the network state
3: ‘ and we will set the starting elevation to the minimum cover
4: ‘ This portion was revised to allow the user to input the starting elevation instead of
5: ‘ setting the starting elevation to the minimum cover.
6: ‘
7: If dLastElevation = c_DBL_MAX Then
8: ‘ To get the program to not ask us for the elevation again we will check to see if the start point z is zero
9: If oPipe.StartPoint.Z = 0 Then
10: dNewPipeZ = ThisDrawing.Utility.GetReal(vbCrLf & “Surface not found, enter invert elevation to use:”)
11:
12: If eFlowDir = aeccPipeFlowDirectionStartToEnd Then
13: ‘ Line below removed to allow the user to provide the invert elevation.
14: ‘ dNewPipeZ = dNewPipeZ + dMinimumCover
15: ‘ The + was a negative sign and Inner was Outer to get invert of the pipe instead of the top of pipe.
16: oPipe.StartPoint.Z = (dNewPipeZ + oPipe.InnerDiameterOrWidth * 0.5)
17:
18: ElseIf eFlowDir = aeccPipeFlowDirectionEndToStart Then
19: ‘ Line below removed to allow the user to provide the invert elevation.
20: ‘ dNewPipeZ = dNewPipeZ + dMinimumCover
21: ‘ The + was a negative sign and Inner was Outer to get invert of the pipe instead of the top of pipe.
22: oPipe.EndPoint.Z = (dNewPipeZ + oPipe.InnerDiameterOrWidth * 0.5)
23:
24: End If
25: End If
26:
27:
28: ‘ otherwise set the starting elevation to the last elevation
29: ‘
30: Else
31:
32: If eFlowDir = aeccPipeFlowDirectionStartToEnd Then
33: oPipe.StartPoint.Z = dLastElevation
34: ElseIf eFlowDir = aeccPipeFlowDirectionEndToStart Then
35: oPipe.EndPoint.Z = dLastElevation
36: End If
37:
38: End If
If you want to go back to the old way just copy over the changed C3DPipeRules.dvb and it should be back to the original state. You can download a hacked version here if you’d like to review.
Excellent post. Thnaks.
Christopher,
I have only experienced the zero elev. pipe invert problem when I XML out my network to Intellisolve to do the hydraulic analysis, make modifications there, then XML back into Civil 3d. The manholes are at proper elevation, but the pipes are not. Is this what you mean when you say, “after you have worked with a pipe (working with a pipe should load the C3DPipeRules.dvb file automatically)”? I would really like to see this address my problem, cause I figure it will be the 2010 release before we see Intellisolve integrated into Civil 3d.
Thanks,
John Cobb, LA
Lexington, KY
We just made the changes as described above and still the rule set for pipes doesn’t do anything if you set “Slope and Cover”. If I use “Cover Only” it seems to work. Does anyone have a working “C3DPipeRules.dvb” they could send?
Mark, I’ve placed my modified version up above, right at the end of the post.
Does the “C3DPiperules.xml” need to be fixed as well? The only rule that seems to run for me is the “Cover Only” rule. If I open a new session and apply the “Cover and Slope” rule to pipes it doesn’t even load the macro. I can load the macro manually but it still seems you need to run it from “Apply Rules..” under the “Pipes” pull-down. All attempts run the macro manually have been unsuccessful.
Any input you can provide is greatly appreciated!
Mark Spatz, E.I.T.
C3D 2008, SP2
Mark, the post only effects how the rule behaves when a pipe is created or when the rules are applied to pipes. It does not go through and change any values until the rules are reapplied. Running the macro manually won\’t do anything productive; it needs to be run through the normal Civil 3D pipe commands that apply the rules. In the pipe properties make sure the pipe has the cover and slope rule as a criteria. Scott Kent gave a good presentation last year at AU that explained how the rules work (http://au.autodesk.com/sessions/detail/444/).
The modification in the above post only affects how the cover and slope rule is applied when no surface is present. It sets the elevation to a user prompted elevation instead of 0 in the default rule. If you want to know how to change the “C3DPiperules.xml” check out my class at AU this year (http://au.autodesk.com/sessions/detail/830/). The handout should be posted this week or next.
Hi Christopher,
i dont know exactly how to make a recent post, because i think my remarks will be usefull for all civil users which work with pipes. First of all thánks very much for your very usefull hacked version of the C3DPipeRules.dvb.
But i found out that there is still a bug in the original and your version if you work with rectangular pipes which have a différnt value for width and height.
The problem are always the line in the code like:
oPipe.EndPoint.Z = (dNewPipeZ + oPipe.InnerDiameterOrWidth * 0.5)
or
oPipe.EndPoint.Z = (dNewPipeZ + oPipe.OuterDiameterOrWidth * 0.5)
This statement is fine for circular pipes but i found out, that it gives you the wrong cover if you apply the slope and cover rule for rectangular pipes, e.g Communication duct with a width of 2.06m and a height of 1.30m.
According my tests if would be better to use instead the following property
oPipe.EndPoint.Z = (dNewPipeZ + oPipe.InnerHeight * 0.5)
or
oPipe.EndPoint.Z = (dNewPipeZ + oPipe.OuterHeight * 0.5)
If you find my remarks usefull maybe you can blog them to all users.
Kind Regards
Peter Bartel