Wednesday, July 30, 2008

Question: VBA Structure Table

Lynn asked:

"Is there any way to create a structure table in civil 3d 2007? I also am very interested in anything you come up with on mitered end sections."

Well I've been busy with other things and haven't gotten to the MES, maybe once the kitchen is done. For the structure table it should be rather quick so I'll go ahead and do a post on this. I'm going to skip most of the beginning steps. One can find the beginning steps from my AU presentation last year. Just like the AU paper I'm using the sample code that comes with Civil 3D:

C:\Program Files\AutoCAD Civil 3D 2009\Sample\Civil 3D API\Vba\Pipe\PipeSample.dvb

Lynn indicated that the table should look like this:


We need the Structure Name, Pipe Description, Top Elevation/Throat Elevation and Invert Elevation. Using the sample code the code for each one of the items would be:

Structure Name

sheetStructures.Cells(iRowStructures, 1).Value = oStructure.Name

Structure Description

sheetStructures.Cells(iRowStructures, 1).Value = oStructure.Description

Top Elevation

sValue = "TOP EL= " & Math.Round(oStructure.RimElevation, 2)
sheetStructures.Cells(iRowStructures, 1).Value = sValue
iRowStructures = iRowStructures + 1

Invert Elevation

sValue = "INV EL= " & Math.Round(oStructure.RimElevation - oStructure.PipeLowestBottomDepth + oStructure.PipeWallThickness(1), 2)
sheetStructures.Cells(iRowStructures, 1).Value = sValue
iRowStructures = iRowStructures + 2

So then we need to put it all together and we get what a report we can run and the structure information will be exported to Excel where we can Paste Special the data into a table in Civil 3D. The code for the invert elevation won't give the correct result if the wall thickness of the pipes entering the structure are not the same. It probably not exactly what you need, but it should get you closer than typing in all the values by hand. I posted the file here (the version is currently 2009, I will change the references tomorrow when I have access to 2007).

No comments:


Blog Widget by LinkWithin