Ad

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

image

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.

image

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.

image

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:

image

And the revised code is shown below:

image

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.

Thursday, February 12, 2009

Angle Between Lines

Just some reminders to myself. VBA.

Dim dPt1(0 To 2) As Double
Dim dPt2(0 To 2) As Double
Dim dAng As Double

Pi equation
Dim pi
pi = 4 * Atn(1)

dPt1(0) = oStructure.ConnectedPipe(i - 1).StartPoint.X
dPt1(1) = oStructure.ConnectedPipe(i - 1).StartPoint.Y
dPt2(0) = oStructure.ConnectedPipe(i - 1).EndPoint.X
dPt2(1) = oStructure.ConnectedPipe(i - 1).EndPoint.Y
dPt3(0) = oStructure.ConnectedPipe(j).StartPoint.X
dPt3(1) = oStructure.ConnectedPipe(j).StartPoint.Y
dPt4(0) = oStructure.ConnectedPipe(j).EndPoint.X
dPt4(1) = oStructure.ConnectedPipe(j).EndPoint.Y

Make sure the lines/points start at the same point to make sure the angle calculated is correct. Absolute in case the angle is negative. 2pi - dAng to get the other angle associated. Much easier than

If dPt1(0) = dPt3(0) And dPt1(1) = dPt3(1) Then
dAng = Abs(ThisDrawing.Utility.AngleFromXAxis(dPt1, dPt2) - ThisDrawing.Utility.AngleFromXAxis(dPt3, dPt4))
ElseIf dPt2(0) = dPt3(0) And dPt2(1) = dPt3(1) Then
dAng = Abs(ThisDrawing.Utility.AngleFromXAxis(dPt2, dPt1) - ThisDrawing.Utility.AngleFromXAxis(dPt3, dPt4))
ElseIf dPt2(0) = dPt4(0) And dPt2(1) = dPt4(1) Then
dAng = ThisDrawing.Utility.AngleFromXAxis(dPt2, dPt1) - ThisDrawing.Utility.AngleFromXAxis(dPt4, dPt3)
ElseIf dPt1(0) = dPt4(0) And dPt1(1) = dPt4(1) Then
dAng = Abs(ThisDrawing.Utility.AngleFromXAxis(dPt2, dPt1) - ThisDrawing.Utility.AngleFromXAxis(dPt3, dPt4))
End If

Tuesday, February 10, 2009

Split TIN Triangle - Elevation Range Point

In the last post I showed a snippet of code to calculate the area of a TIN Triangle for the entire triangle. This post will show a way to calculate the point where the elevation range splits a side of a TIN Triangle. The code checks both cases of the elevation range splitting the triangle length. The If Then statement checks the item in brackets first and then compares the Or statement.

Dim dPt(0 to 2) As Double ' X,Y,Z

Dim dElev As Double

dElev = 38

' Check to see if the TIN Triangle sides are split by an Elevation Range.

If (dOT(i + 2) > dElev And dOT(i + 5) < dElev) Or (dOT(i + 2) < dElev And dOT(i + 5) > dElev) Then

dPt(0) = dOT(i) - ((dOT(i + 2) - dElev) * (dOT(i) - dOT(i + 3)) / (dOT(i + 2) - dOT(i + 5))) ' X
dPt(1) = dOT(i + 1) - ((dOT(i + 2) - dElev) * (dOT(i + 1) - dOT(i + 4)) / (dOT(i + 2) - dOT(i + 5))) ' Y
dPt(2) = dElev ' Z

End If
...

The equations show the first side of the triangle, the other two sides are similar. To help you out here are the equations reduced to X,Y,Z notation.

If (Z1 > dElev And Z2 < dElev) Or (Z1 < dElev And Z2 > dElev) Then

X' = X1 - ((Z1 - dElev) * (X1 - X2) / (Z1 - Z2))
Y' = Y1 - ((Z1 - dElev) * (Y1 - Y2) / (Z1 - Z2))
Z' = dElev ' Z

End If

So that's one way to calculate the point where the elevation range crosses the TIN Triangle. If you do use the code you'll want to make sure that the denominator does not equal to 0, since it isn't possible.

Monday, February 09, 2009

2D Area of a TIN Triangle

This post is a snippet of code that calculates the 2D area of a TIN Triangle. This is helpful to know if you want to calculate Elevation ranges for a TIN surface.

dOT is an array of TIN Triangle points for the entire surface using the OutputTriangles Property for an AECTINSurface.

For i = 0 to Ubound(dOT) Step 9

dArea = dArea + 0.5 * Abs(dOT(i)*dOT(i+7)-dOT(i)*dOT(i+4)+dOT(i+3)*dOT(i+1)-dOT(i+3)*dOT(i+7)+dOT(i+6)*dOT(i+4)-dOT(i+6)*dOT(i+1))

Next

This is just part of the area calculations needed. You would also need to calculate the area of the triangle if it is split by an elevation range or ranges.

Civil 3D 2010 - 64 Bit?

We'll if you've watched the 2010 AEC Product Launch Webcast, you'll notice that one of the questions was unable to be heard. The question I'm referring to is:

Q: If Map 3D 2010 supports 64-bit operating systems, will Civil 3D 2010 also support 64-bit systems instead of running as a 32-bit program in 64-bit environment?

Now this question is of interest to me because I use Vista as a 64-bit Operating System at home. I was a bit disappointed that the answer indicated that it wasn't going to be included in this release.

A: Civil 3D 2010 does not take full advantage of 64-bit systems at this time however it is a high priority for future releases

Hopefully 2011 will bring a Civil 3D that runs natively on a 64-bit system.

If your looking for more information on Civil 3D 2010 I'd start looking for other blogs posts later this evening. I suspect James over at Civil3D.com will be one of the first with posts regarding the new product.

LinkWithin

Blog Widget by LinkWithin

Ad