In last day or so Autodesk have announced the release of the new Volume Dashboard add on for Civil3d 2012 subscription users.
About a month or so ago a I bolted together a number of pieces of code off the net from here, here and here. To make my own utility to generate a bounded volumes table for a project. The routine uses polylines for stage boundaries and a single bounded volume surface, here is a quick video of the code in action and the code I developed for those users that want to use it in previous versions of Civil3d. The code may also be useful to dump the results of the stages volumes into a standard Autocad table a functionality that is lacking in the new tool.
I did plan to develop the code further to remember the stage boundaries polylines by attaching the handle of the staging polylines to the volume table as xdata to enable a table refresh at a later date.
Instead I will continue to focus on cleaning up XPac a collection of code routines I have written over the last 5 to 6 years for Civil3d. Here is a compiled version of XPac with the command XP_BoundedVolumeTable command as always use the code at your on risk.
Here is the code.
<CommandMethod("XP_BoundedVolumeTable")> _
Public Sub Bounded_Surface_Volumes()
'Prompt the user if the they want to create a new bounded volumes table or refresh an existing one
'If new then get the user to
'Select the volume surface
Dim ObjTypetoSelect(0) As Type
ObjTypetoSelect(0) = GetType(TinVolumeSurface)
Dim surfaceId As ObjectId = PromptForTinSurface(ObjTypetoSelect, "Select a TIN Volume Surface: ", "The selected object is not a TIN Surface.")
If ObjectId.Null = surfaceId Then
_write(vbLf & "No TIN Surface object was selected.")
' We don't have a surface; we can't continue.
Return
End If
'Create a selectionset of the polylines to be used the bounded polylines
Dim acSSet As SelectionSet = GetSelectionSet()
'check selectionset not null
If acSSet.Count = Nothing Then
Exit Sub
End If
'Define the and size an array to sort the volume data for use later
Dim VolumeData As String(,) = New String(acSSet.Count + 1, 3) {}
Dim polylinenum As Integer = 2
'for each polyline in the selection
'create an array of vertice co-ords to pass to volume function
For Each acSSetObj As SelectedObject In acSSet
Dim dObjId As ObjectId
dObjId = acSSetObj.ObjectId
If (dObjId.IsNull) Then
m_Editor.WriteMessage("No Bounding Polylines have been selected")
Return
End If
Try
'not sure if you can get bounded volumes in .net yet therefore
'from the ObjectID get a com surface object to use the boundedvolumes method
Using tr As Transaction = startTransaction()
'get the bounding polyline for read
Dim oPolyline As Polyline = tr.GetObject(dObjId, OpenMode.ForRead)
'Determine the volumes in the polylines area
Dim oCutFillSurface1 As AeccTinVolumeSurface = tr.GetObject(surfaceId, OpenMode.ForRead).AcadObject
Dim oCut As Double = 0
Dim oFill As Double = 0
Dim oNet As Double = 0
Dim oArray As New List(Of Double)
oArray = ArrayOfPolylineCoords(oPolyline)
Dim xx As Object
xx = oArray.ToArray
oCutFillSurface1.Statistics.BoundedVolumes(xx, oCut, oFill, oNet)
'ReDim VolumeData (1,2) Perserve
VolumeData(0, 0) = "EARTHWORK VOLUMES"
VolumeData(1, 0) = "Stage"
VolumeData(1, 1) = "Cut"
VolumeData(1, 2) = "Fill"
VolumeData(1, 3) = "Net"
VolumeData(polylinenum, 0) = polylinenum - 1
VolumeData(polylinenum, 1) = Math.Round(oCut, 2).ToString
VolumeData(polylinenum, 2) = Math.Round(oFill, 2).ToString
VolumeData(polylinenum, 3) = Math.Round(oNet, 2).ToString
polylinenum = polylinenum + 1
End Using
Catch ex As System.Exception
MsgBox("Error in calculating volumes from polyline" & Err.Description & " - " & Err.Number & Convert.ToChar(10))
Return
End Try
Next
'CreateTable(VolumeData)
CreateTableWithStyleAndWhatStyle(VolumeData)
'add volume data to an array
'next
'Insert a table into the drawing of the volumes.
End Sub
No comments:
Post a Comment