Sometimes it's interesting, to me at least, where this blog site is linked from. Recently I saw a link coming from ww3.cad.de, 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.