Sunday, January 27, 2008

Sample VBA Code

While working on some code to export data from Civil 3D to HEC-RAS I found that the existing HEC-RAS Report (which wasn't completed by Autodesk) has some good starting points to create your own custom VBA Programs.

It has a list box to collect all of the alignments in a drawing, code to write to a text file and a way to have the user save the file. It also has good examples on how to use Class Modules to pass values between modules.

Sunday, January 20, 2008

Vertical Curve Across Profile

vSometimes a vertical curve crosses between sheets, like the picture below:

The way I get past this problem is to create a style for the left side and the right side. The problem in the label is that the dimension line that goes across references both vertical portions of the label. Since Civil 3D doesn't draw the right line (as in the case of the picture above), it puts the label information on the left side of the label.

Go in and copy the vertical curve label. Go in and change the anchor point for the Use End Point Anchor to false. If you exit the label composer you will find the length of the dimension line is either to short or to long. To get the correct length of the dimension line take the End of the Profile View minus the BVCS and then divide by the drawing scale to get the required distance of the dimension line. Now make the dimension arrow to the right to not show.

The label should look like something like this:

Now just create one for the right side. Since in the office I work we have on drawing per sheet, we just need one style. If you have more than one sheet per drawing you will have a bunch of additional label styles or children.

A link to the left side label.

Thursday, January 17, 2008

Templates and Styles

Did you know that just like Civil 3D, Microsoft Word has templates and styles? In my experience most people don't, even the people who should. So the next time you have to create a document using Word check out the styles and templates and see if can help you have a uniform look throughout the document.

Saturday, January 05, 2008

Using NORTH, EAST, SOUTH and WEST in a Bearing Label

A poster in the DG was looking for a way to have NORTH, EAST, SOUTH and WEST in a bearing label instead of having a label with lots of zeros (N0'00"E). One way to accomplish this is to use expressions. Set up an expression for each of the whole directions and one for all of the other directions. I called mine North, East, South, West and Other. For the expression formula use something that looks like what is below:
IF({Segment Direction}=pi,(0.1/12),0.000001)

The (0.1/12) is if the if statement is true and set the height of the text that we would want. The 0.000001 is if the expression is false and sets the text height so it won't be seen when we print out the sheet.

The list below summarizes the angles for each whole direction:
North = 0
East = 3*pi/2
South = pi
West = pi/2

The expression for the Other should eliminate all of the whole angles, the expression is below:
IF({Segment Direction}=0,0.000001,IF({Segment Direction}=pi/2,0.000001,IF({Segment Direction}=3*pi/2,0.000001,IF({Segment Direction}=pi,0.000001,(0.1/12)))))

Now create a text component for each expression. The Other will have the Segment Direction and the whole directions will have the word that you want to show. For instance if the Segment Direction is 0 use North.

If you use this in production you will probably need to change the formula to take in account rounding. To do this use an expression that looks like something below:

IF({Segment Direction}<(pi+0.00000194),IF({Segment Direction}>(pi-0.00000194),(0.1/12),0.000001),0.000001)

The 0.00000194 should be approximately 0'0.4".

You will have to make the change for each label. The labels I came up may be found here under the 01-05-2008 heading.

Thursday, January 03, 2008

Pipe Rules - Using Custom Descriptions

When you create your custom rule, you will probably want to use a custom name for the input you want to use. To do this use the code from the Set Sump Depth Rule. The applicable code snippet is the following:

' Get the doubles parameters
Dim oParamsDouble As AeccPipeParamsDouble
Set oParamsDouble = oNetworkState.ParamsDouble

' Hardcoded for Service Pack 1. Will globalize for C3D 2008 (Cannon).
Dim strSumpDepth As String
strSumpDepth = "Sump Depth"

Dim dSumpDepth As Double
dSumpDepth = oParamsDouble.Value(strSumpDepth)

The item in quotations is what is shown in the DisplayName in the Civil3DRules.xml file, so just change "Sump Depth" to match what is set in your rule.


Blog Widget by LinkWithin