Ad

Thursday, January 08, 2009

Pipe Slope Along a Run

Civil 3D provides several ways to change the slope of pipes. You can use Prospector, right clicking and viewing the pipe's properties, grip editing the pipe or using pipe rules. Apart from the rules there is a limited number of ways to adjust the slope of a pipe run. The pipe rules, Cover and Slope, may be problematic for a run of pipes since the cover makes it difficult to get a slope at a constant grade. I did post about the availability of a Slope Only rule that I came up with for a coworker in Colorado, but nobody seemed interested in it. I'm just glad no one has asked for it recently because I think I misplaced the rule. For this post I'm going to be working outside of the rules and going with VBA.

I've covered on how to set up the VBA in pasts posts, so I'll skip it here. Once you have the VBA project set up we can go ahead and start programming. The first thing we need to do is get some information from the user.

image

So now that we have the pipes or structures and required slope we can modify the pipe slopes. The first thing we need to do is get the pipe application which is the AutoCAD object that contains all of the pipe information, which is borrowed from the sample file that comes with Civil 3D.

image

Now we need to get the pipe networks of the pipe parts selected to make sure the pipes/structures are in the same pipe network. Since we need to find it for each structure we'll use a separate Function to find the pipe network names. When using the Functions you can pass objects from the Sub to the Function and then return the value. The arrows are trying to illustrate what is being passed and where they are placed.

image

The code goes through all of the pipe networks in the drawing and then checks to see if the pipe or structure is included in the pipe network. So now that the pipe networks are known we can see if they are in the same network, if not the program will end using the Exit Sub.

image

So now we need to get all of the pipes and structures from the first pipe/structure selected and the second pipe/structure selected. To do that use the FindShortestNetworkPath method of the pipe network of the selected pipes/structures. The code below sets the pipe network and then creates an array based on what type of objects where selected (hopefully I covered all of the scenarios).

image

So now that we have the pipes/structures in an array the code will go through and change the slopes and elevations of the pipes. The code uses the first pipe's start elevation for the beginning elevation and then apply the elevations and slopes to the pipes. The structure's won't be changed, although they probably should be updated after adjusting the slopes and elevations. The last object selected, if it is a pipe, needs to be calculated separately since it is not included in the array for some reason.

image

So that's the code to do it. It could use some more code, maybe for recognizing that the pipes are going the opposite direction, but hey you don't pay for this. Here's a page that has the code as it is now: http://style.civil3dreminders.com/setpipeslopeonrun

11 comments:

Anonymous said...

Nice programming but is there any way to add a 0.10' drop at each manhole?

Christopher Fugitt said...

Sure there is. Change the following (from the last picture in the post):
dElev = oPipe.StartPoint.Z
to
dElev = oPipe.StartPoint.Z - 0.10

and change

oPipe.StartPoint.Z = dElev
to
oPipe.StartPoint.Z = dElev + 0.10

Anonymous said...

When I alter those lines of code I get my 0.10' drop but my slopes are now different than what I enter.

Christopher Fugitt said...

Sorry, I missed changing this line:

oPipe.EndPoint.Z = dElev + (oPipe.Length2D * dSlope)

To

oPipe.EndPoint.Z = dElev + 0.10 + (oPipe.Length2D * dSlope)

Anonymous said...

That did the trick, thanks

Anonymous said...

Thanks a lot, I've been looking for something like this. One thing is that my when I run the macro and change slopes, the pipes update in profile view but the structures do not. They update eventually if I change the sump depth and the back to what it was, so its not a huge pain. Just wondering if that can be fixed within the macro? Thanks again.

Christopher Fugitt said...

I'll try to do a post that will update the structures tonight.

Anonymous said...

I know this is an old thread, but any suggested edits to have the vba ignore the direction the pipe has been drawn? The vba as it is operates using start and end inverts, however, most of our designers don't consider the direction of flow when placing their start and end of pipes

Christopher Fugitt said...

There is a property on the pipe that will tell you what direction the pipe was placed on, make a check to see and then do the opposite ends if it is.

Anonymous said...

I know this is a super old thread, but hoping this works, when I run the above I get "Compile error: User-defined type not defined" and it highlights the line "Function FindPipeNetworkName (oPipe1 As AeccPipe,.....) As String. Any help would be greatly appreciated.

Christopher Fugitt said...

Did you update the references to the current version of Civil 3D in VBA?

LinkWithin

Blog Widget by LinkWithin

Ad