Compute materials results and dynamo

hello, i have a question, there is a node in dynamo that allows me to extract compute material results generated in civil 3d? by the analysis name.

Are you talking about section materials? A screenshot would help.

Yes, i have computed the materials in the current section, in the image, the first material with the blue hatch is in 2 analisis ( 1 and 2) and the material with the red hatch in other 2 parts ( 3 and 4)

i was wondering if dynamo allows me to take the final result in the material tables and combine the amounts.

Sadly, as of my knowledge after researching this for a few month back in spring there is no easy way.

There are 2 types for materials shapes and sections. For corridor shapes, there is no direct way that I know of to access the calculated section data. You have to recalculate it manually using this:
https://help.autodesk.com/view/CIV3D/2023/ENU/?guid=efe2c90f-ccdd-015b-c15e-e4744e2ad884

In your case for sections there is a more simple way, but also have to do it in Python. You can access the created material sections and get area values, (maybe volumes too I don’t remember) from that and stations volumes can be calculated.
Example to get section data:

# Load the Python Standard and DesignScript Libraries
import sys
import clr

# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')

# 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 from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

aDoc = Application.DocumentManager.MdiActiveDocument
editor = aDoc.Editor
cDoc = CivilApplication.ActiveDocument

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 = []
    volumeres = []
    result = []
    error_report = None

    try:
        # 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)
                                mGuids.append(mGuid)

                            # Get material names in mapping and total volume
                            # result data for material list
                            for n in mGuids:
                                matName = slg.GetMaterialNamesInMapping(n)
                                matNames.append(matName)
                                volume = slg.GetTotalVolumeResultDataForMaterialList(n)
                                ##volumetype = volume.kMaterialStructureVolume
                                volumes.append(volume)
                                qtoSectionalResult = volume.GetResultsAlongSampleLines()
                                length = qtoSectionalResult.Length
                                for i in range(length):
                                    qtoAtStation = qtoSectionalResult[i]
                                    volumeresatstation = qtoAtStation.AreaResult
                                    fill = volumeresatstation.FillArea
                                    volumeres.append(fill)
                                result = [mNames, mGuids, matNames, qtoSectionalResult,volumeres]
                                return result
    except:
        import traceback
        error_report = traceback.format_exc()

# Output	
OUT = get_slg_vol_result()

Volume tables cannot be accessed.

@mzjensen maybe considering some Camber nodes for this nonsense? :smile:

1 Like

hey, thanks , i gonna try the code.

Hi, i tried to get the areas within the sectionmaterials with C#, seems like you, but didnt have a good result. Because my code as your code only get the area for fills by material(all materials at the same time) but dont get material by material and structures too. Do you hace idea how we get the areas in the materialsections material by material?

Well, after a long research I am positive that areas are inaccessible directly. The thing we did was getting the section point collection and basically redrew all material sections. Not the most effective way, but the only that we found.
As an alternative you can use AppliedAssembly Class and then getting CalculatedShapes, but it has to be done for all baselines.
https://help.autodesk.com/view/CIV3D/2023/ENU/?guid=6a7885c4-7fec-e770-d066-57b3bc1337f6
https://help.autodesk.com/view/CIV3D/2024/ENU/?guid=de3a9ed4-2dc4-7287-5c63-f8772babf27d

I hope I helped