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])