SectionVolume Example

Land Auto

SectionVolume Example

Sub Example_SectionVolume()
    
    ' This example calculates the volume data for the second cross section in the
    ' cross section collection for the first alignment in the collection.
    Dim aligns As AeccAlignments
    Dim align As AeccAlignment
    Dim xSect As AeccCrossSection
    Set aligns = AeccApplication.ActiveProject.Alignments
    Set align = aligns.Item(0)
    Set xSect = align.CrossSections.Item(0)
    
    ' Get the cross section station and format it
    Dim station As String
    station = aligns.DoubleToStaFormat(xSect.station)
    
    ' Define result variables
    Dim cutArea As Double
    Dim cutCentroid As Double
    Dim cutVolume As Double
    Dim fillArea As Double
    Dim fillCentroid As Double
    Dim fillVolume As Double
    
    ' Get volume data
    xSect.SectionVolume kVolumeByAvgEndArea, 1#, 1#, 1#, cutArea, cutCentroid, cutVolume, fillArea, fillCentroid, fillVolume
    
    MsgBox "The volume data at station " & station & " is: " & vbCrLf & _
        "Cut Area: " & Format(cutArea, "0.00") & vbCrLf & _
        "Cut Centroid: " & Format(cutCentroid, "0.00") & vbCrLf & _
        "Cut Volume: " & Format(cutVolume, "0.00") & vbCrLf & _
        "Fill Area: " & Format(fillArea, "0.00") & vbCrLf & _
        "Fill Centroid: " & Format(fillCentroid, "0.00") & vbCrLf & _
        "Fill Volume: " & Format(fillVolume, "0.00"), vbInformation, "SectionVolumn Example"
    
End Sub