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

7 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.

LinkWithin

Blog Widget by LinkWithin