I have a corridor with multiple regions using the same assembly. Some of the feature lines exist in some regions and not in others based on inputs.
->I need to get the region name of each of the associated feature lines.
I see no OOTB nodes to get this so i went to Python and tried the following from here - Extract (auto)Corridor Featurelines - Civil 3D - Dynamo
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
oid = autoFeatureLine.InternalObjectId
obj = t.GetObject(oid, OpenMode.ForRead)
region = obj.CorridorFeaturelineRegionName
t.Commit()
pass
OUT = region
Sadly with statements don’t work well in CPython as the parent object doesn’t inherit the right methods. A fix will require restructuring your code to avoid the with statements, and thereby require you manually close each statement.
If you change the Python version (e.g.Ironpython 2.7) the warning indeed says that dynamonodes.corridorfeatureline doesnt have either internalobjectid or internaldbobject property.
As a workaround you can create the feature lines in civil and use the db objects via object selection. With actual feature lines the script worked for me.
thanks kovacsv, thats interesting and noted as a backup but i have far to many to manually do this every time we run the script. Hoping to get a solution without the need to create the feature lines separately.
To convert from a Dynamo object to a Civil 3D object I always just take the handle from the Dynamo object and then get the object from the handle using the C3D API. Ideally that happens before the ‘with’ statements start.
Tip: OUT = dir(obj) where object is the thing you have will usually return the full context of what you can do with a thing. So if you have your Baseline.CorridorFeatureLinesByCode as the variable autoFeatureLine you can run set the very next line to be OUT = dir(autoFeatureLine) and then comment out everything after it. Run that and you should get an indication of how to find the handle if you read over what you can do with the element. Just be sure you only have one feature line in, otherwise you’ll be getting the things you can do with a list.
I would like to suggest you use traceback to catch your errors. That way your document will unlock and you get to catch more specific errors. Also no need to Commit if you are not amending I guess.
The original from the post from mzjensen works fine for me indeed.
I’m running on 2024, no packages. That may be different, but I suspect not, since the 2024 documentation is same as 2025…
Note: The properties you are getting with dir are Dynamo Featureline Properties wich is a different class. The Autodesk.Civil.DatabaseServices.AutoCorridorFeatureLine soes not give PolyCurve as a Property.
Note: the original script is taking 1 AutoCorridorFeatureLine, you are giving a list. To report multiple you have to nest your code in a loop:
import clr
clr.AddReference('AcMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AeccDbMgd')
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
autoFeatureLines = IN[0]
adoc = Application.DocumentManager.MdiActiveDocument
regions = []
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
for fl in autoFeatureLines:
oid = fl.InternalObjectId
obj = t.GetObject(oid, OpenMode.ForRead)
regions.append(obj.CorridorFeaturelineRegionName)
t.Commit()
pass
OUT = regions
Agreed, Yes i have since noticed it was Dynamo Featureline from dir. So we can disregard that for now.
I just tried your updated code for multiple regions and I get the same error
TypeError : No Method match given arguments for OnExit…
I tried one and multiple same result. Just tried in C3D 2023 same result also. See below for basic test node layout.
I strongly suggest you use traceback to catch the real error. “TypeError : No Method match given arguments for OnExit…” Is just a main error whereas with traceback you get logic feedback on whats really going on. So add:"
import clr
import traceback
clr.AddReference('AcMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AeccDbMgd')
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
autoFeatureLines = IN[0]
adoc = Application.DocumentManager.MdiActiveDocument
regions = []
err = None
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
try:
for fl in autoFeatureLines:
oid = fl.InternalObjectId
obj = t.GetObject(oid, OpenMode.ForRead)
regions.append(obj.CorridorFeaturelineRegionName)
#t.Commit()
except:
err = traceback.format_exc()
if err:
OUT = err
else:
OUT = regions