Get Total Volume Result Data For Material List

I’m trying to create a function in Python that will produce earthwork and material volume reports for all the materials in a sample line group (similar to the _AeccGenerateQuantitiesReport command). I have managed to get the total volume result data for each material list in a sample line group but struggling to find a method in the .net API that exposes what’s in the total volume result data.

Attached is a drawing to test the python script with. Any suggestions would be much appreciated.

SLG vol.dwg (1008.9 KB)

# Load Python standard libraries
import clr

# Add Assemblies for AutoCAD and Civil 3D APIs

# Add standard Python references
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')
import os
import math

# Add references to manage arrays, collections and interact with the user
from System import *
from System.IO import *
from System.Collections.Specialized import *
from System.Windows.Forms import MessageBox

# Create an alias to the Autodesk.AutoCAD.ApplicationServices.Application class
import Autodesk.AutoCAD.ApplicationServices.Application as acApp

# Import references for Civil 3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

# Import references for PropertySets
from Autodesk.Aec.PropertyData import *
from Autodesk.Aec.PropertyData.DatabaseServices import *

# Declare global variables
aDoc = acApp.DocumentManager.MdiActiveDocument
ed = aDoc.Editor
cDoc = CivilApplication.ActiveDocument

# Functions

def get_slg_vol_result():
    This method gets the total volume result data for material list
    associated with a sampleline group.
    :param mappingGuid: 
    :return: Volume result data.
    global aDoc
    global ed
    global cDoc

    # Instantiate empty lists
    mNames = []
    mGuids = []
    matNames = []
    volumes = []	
    result = []
    error_report = None

        # Get the active document in the AutoCAD session:
        with aDoc.LockDocument():
            with aDoc.Database as db:
                with db.TransactionManager.StartTransaction() as t:
                    # Get the objectId collection of all Alignment objects in the drawing
                    alignmentId = cDoc.GetAlignmentIds()

                    # Get the alignment
                    for a in alignmentId:
                        alignment = t.GetObject(a, OpenMode.ForRead)
                        # Get the object collection of all sample line groups 
                        # belonging to alignment
                        for s in alignment.GetSampleLineGroupIds():
                            slg = t.GetObject(s, OpenMode.ForRead)

                            # Get the SLG QTO Mapping Names
                            mNames = slg.GetQTOMappingNames()
                            # Get the SLG mapping global unique identifier
                            for m in mNames:
                                mGuid = slg.GetMappingGuid(m)

                            # Get material names in mapping and total volume
                            # result data for material list
                            for n in mGuids:
                                matName = slg.GetMaterialNamesInMapping(n)
                                volume = slg.GetTotalVolumeResultDataForMaterialList(n)

                                result = [mNames, mGuids, matNames, volumes]
        import traceback
        error_report = traceback.format_exc()
    if error_report == None:
        return result
        return error_report

# Output	
OUT = get_slg_vol_result()

Hi @Alex.ColeAAFHE

Are you trying to get Cum. Fill Volume?

Hi @Kulkul - for starters it’s fantastic to see what I’m trying to achieve is possible in Python :grinning:. To be clear I’m trying to access all the results used to create these reports:

  1. earthwork.xsl for the Cut and Fill material list.

  2. Select Material for the material list

What class and method/property are you using to get that information? Is it located in .net API or COM?

It’s available in .NET API. Check this out:!!MEMBEROVERVIEW_Autodesk__Civil__QTO__DatabaseServices__QTOVolumeResult.htm