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.