Extract Solids for Multiple Corridors

Good news everyone!
This is now covered in the 2023.2 Update API.

Here’s a test script:

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

from System import Array

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

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

corridorin = IN[0]
exludedcodesin = IN[1]

with adoc.LockDocument():
    with adoc.Database as db:

        with db.TransactionManager.StartTransaction() as t:
            # Place your code below
            for i in range(len(corridorin)):
				exlcodes = Array[str](exludedcodesin[i])
				#for i in range(len(exludedcodesin)):
				#exlcode = Array[str](exludedcodesin)
				#exlcodes.Append(exlcode)
				#exlcodes = ["0", "Top"]
				corridorId = corridorin[i].InternalObjectId
				# Open corridor object
				corridor = t.GetObject(corridorId, OpenMode.ForWrite)
				param = ExportCorridorSolidsParams()
				param.ExcludedCodes = exlcodes
				export = corridor.ExportSolids(param,db)
            # Commit before end transaction
            t.Commit()
            pass

# Assign your output to the OUT variable.
OUT = exludedcodesin[0]

Included or excluded codes have to be defined in the ExportCorridorSolidsParams() Class
These should be string arrays.

11 Likes