Add criteria for material list

Hi everyone. I’m trying to add a quantity takeoff criteria for material list to a sample line group. To assign object names to surfaces and corridor shapes I’m planning to use an Excel. What I need to know is how to access the compute materials options. I’ve nodes to create and edit quantity takeoff material criterias but I already have that done manually. I hope you can help me. Thanks.

image

PD: My plan is to add the quantity takeoff criteria to the sample line group first and the create the sections. If that is not the correct way to do that please correct. I’m not sure if I should create the sections first and then add the criteria. Thanks again.

Hi,
please take a look at this thread, it might help.

This basically does the same as the Compute Materials icon with mapping.

I can understand it but I think that that graph does create a new quantity takeoff criteria, add corridor shapes and then, with the Python script, assign it to a sample line group. Am I right?
I’m going to try it. Thank you so much.
Just one question: do you think there is a way to use an already existing quantity takeoff criteria? Thanks again.

Yeah sorry, I made this back in May and did not use it since so I’m not 100% sure what is happening, but if I’m correct the python scipt does the job (mapping and computing) everything outside is optional. We wanted to skip mapping and creteria creation, for every corridor a unique criteria is created with the coded shapes of the corridor and then that is mapped and computed. But if you already have criterias that part can be skipped. I think the script’s first input is the criteria itself.
So in theory you can use your criteria and selected shapes. But as you can see there is a variable to check if everything is mapped, and if it is false, so not everything is mapped in the criteria I think the CriteriaImport(aka Compute Materials) can’t be done, hence the graph is created this way to avoid this as the criterias are created from the shapes to be mapped.

Sorry to ask. How could I map a criteria that uses surfaces (for cut and fill for example)? I think I would be to add the criteria item but I don’t know how to add the surfaces. Thanks again for your responses.

You can change the MapCorridorShape() Method to MapSurface() using the correct inputs.
https://help.autodesk.com/view/CIV3D/2023/ENU/?guid=5cf12b59-3a03-f6e2-0210-8decfffe2ca9
But I never used that so I’m not exactly sure how to apply the inputs.

1 Like

Hi. I’ve using the MapSurface method to map two surfaces for a cut and fill criteria and I get this error.
I think it has something to do with the isMappingCompleted method but the criteria only asks for two surfaces.
Can you guide me in what’s missing? Thanks.


The code in Python is this:

# 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 *

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

def addsurfacetoslg(QTOC,SLGl,TN,nameTN,SUBRAS,nameSUBRAS):

#QTOC - QTOCriteria created from all the shapes from one corridor (Camber, ArkanceSystems Corridorshapes)
#SLGl - sample line group list
#CORR - selected corridor
#shapes - list of shapes in that corridor, QTOCriteria made from that

	global adoc
	
	with adoc.LockDocument():
		with adoc.Database as db:
			with db.TransactionManager.StartTransaction() as t:
				#get input QTOCriteria object id
				QTOCid = QTOC.InternalObjectId;
				#QTOCo = t.GetObject(id, OpenMode.ForWrite, True);
				for slg in SLGl:
					#get sample line group object id
					slgid = slg.InternalObjectId;
					#open sample line group object
					slgo = t.GetObject(slgid, OpenMode.ForWrite, True);
					#create criteria name mapping for sample line group from QTOCriteria 
					QTOM = QTOCriteriaNameMapping(QTOCid,slgid);
					#sampled input surface id
					TNid = TN.InternalObjectId
					SUBRASid = SUBRAS.InternalObjectId
					#map every shape from input to every shape in criteria (error if not all the same, not solved in code yet)
					surfacemapping1 = QTOM.MapSurface(nameTN,TNid)
					surfacemapping2 = QTOM.MapSurface(nameSUBRAS,SUBRASid)
					#TRUE if all surface mapped
					completed = QTOM.isMappingCompleted
				#add created mapping to sample line group aka compute materials
				importcriteriatoslg = QTOMaterialListCollection.ImportCriteria(slgid.MaterialLists,QTOM)
				t.Commit()
				return completed

# Assign your output to the OUT variable.
OUT = addsurfacetoslg(IN[0],IN[1],IN[2],IN[3],IN[4],IN[5])

When I run it I get this:

IMG-20221117-WA0014

First please set the python script node IronPython2 so Dynamo hopefully does not crash and it displays more specific error.