How can I extract areas from a sctructure type material list

Hey guys!
I’m trying to extract the areas by station from my bills of materials. The fill and cut areas of a cut and fill type bill of materials, I can do it! But I’m trying to collect the structure-type areas and I’m not succeeding. Here’s my dynamo routine. And my python script.


Load the Python Standard and DesignScript Libraries

import sys #sys is a fundamental Python library - here, we’re using it to load in the standard IronPython libraries
import clr #This is .NET’s Common Language Runtime. It’s an execution environment that is able to execute code from several different languages.

Add Assemblies for AutoCAD and Civil3D

clr.AddReference(‘AcMgd’)
clr.AddReference(‘AcCoreMgd’)
clr.AddReference(‘AcDbMgd’)
clr.AddReference(‘AecBaseMgd’)
clr.AddReference(‘AecPropDataMgd’)
clr.AddReference(‘AeccDbMgd’)
clr.AddReference(‘ProtoGeometry’) #A Dynamo library for its proxy geometry
#classes. You’ll only need this if you’re interacting with geometry
clr.AddReference(‘AeccPressurePipesMgd’)
clr.AddReference(‘acdbmgdbrep’)
clr.AddReference(‘Civil3DNodes’)
clr.AddReference(‘AutoCADNodes’)

import Autodesk #Loads the Autodesk namespace

Import references from AutoCAD

AAR = Autodesk.AutoCAD.Runtime
AAA = Autodesk.AutoCAD.ApplicationServices #Setting a handle to the currently-open instance of the AutoCAD application
AAD = Autodesk.AutoCAD.DatabaseServices
AAE = Autodesk.AutoCAD.EditorInput
AAG = Autodesk.AutoCAD.Geometry
AADy = Autodesk.AutoCAD.DynamoNodes

AUX = Autodesk.Aec.DatabaseServices

OP = AAD.OpenMode
TS = AAD.Transaction

Import references from Civil3D

ACA = Autodesk.Civil.ApplicationServices #Setting a handle to the currently-open instance of the Civil3D application
ACD = Autodesk.Civil.DatabaseServices
ACDy = Autodesk.Civil.DynamoNodes

AD = ACA.CivilApplication.ActiveDocument #Finally, setting up handles to the active Civil3D document
AC = Autodesk.Civil

adoc = AAA.Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor

#Inputs:
#IN[0] → Alinhamento

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
       lista  =[]
       lista.append(IN[0].AcadObjectId)
       alignmentId = lista
       slg = []
       mNames = []
       mGuid = []
       volume =[]
       qtoSectionalResult =[]
       CorteArea =[]
       AterroArea =[]
       vt = []
       # Get the alignment
       for a in alignmentId:
           alignment = t.GetObject(a, OP.ForRead)
           # Get the object collection of all sample line groups 
           # belonging to alignment
           for s in alignment.GetSampleLineGroupIds():
               slg.append(t.GetObject(s, OP.ForRead))
               # Get the SLG QTO Mapping Names
       for l in slg:
            mNames.append(l.GetQTOMappingNames())
               # Get the SLG mapping global unique identifier
       NOMELISTA = []
       for i in mNames:
           NOMELISTA_aux = []
           for j in i:
               if j == "CFT":
                   NOMELISTA_aux.append(j)
           NOMELISTA.append(NOMELISTA_aux)
           
       for i in range(0,len(NOMELISTA)):
           aux_mGuid = []
           aux_volume =[]
           aux_vt = []
           for j in NOMELISTA[i]:
               amGuid = slg[i].GetMappingGuid(j)
               aux_volume.append(slg[i].GetTotalVolumeResultDataForMaterialList(amGuid))
               aux_mGuid.append(amGuid)
           mGuid.append(aux_mGuid)
           volume.append(aux_volume)
           vt.append(aux_vt)
       for i in range(0,len(volume)):
           aux_qtoSectionalResult =[]
           for j in volume[i]:
               aux_qtoSectionalResult.append(j.GetResultsAlongSampleLines())
           qtoSectionalResult.append(aux_qtoSectionalResult)
       
       for i in range(0,len(qtoSectionalResult)):
           aux_cut_ = []
           aux_fill_ = []
           for j in range(0,len(qtoSectionalResult[i])):
               aux_cut = []
               aux_fill = []                   
               for z in range(0,len(qtoSectionalResult[i][j])):
                   Area = qtoSectionalResult[i][j][z].AreaResult
                   aux_cut.append(Area.CutArea)
                   aux_fill.append(Area.FillArea)
               aux_cut_.append(aux_cut)
               aux_fill_.append(aux_fill)
           CorteArea.append(aux_cut_)
           AterroArea.append(aux_fill_)
       t.Commit()

OUT = CorteArea

Hi
Looking at this

1 Like

Yes, I had already seen this post. But his doubt is the same as mine. I decided to post again because it’s been a few months since the last one.

I’m thinking of giving up on finding via QTO Material and testing via the assembly shape area. But I’m not finding something in the API that connects the samplelines with the corridor shapes.

Hi
Iam not sure if this will help you

1 Like