# Get Region Name of FeatureLine

**URL:** <https://forum.dynamobim.com/t/get-region-name-of-featureline/110379>\
**Category:** Civil 3D\
**Tags:** python\
**Created:** [May 26, 2025, 6:31am UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379 "2025-05-26T06:31:27Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![aa047](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@aa047](https://forum.dynamobim.com/u/aa047)\
**Post date:** [May 26, 2025, 6:31am UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/1 "2025-05-26T06:31:27Z")

</div>

Hi All,  
Using C3D 2025.2

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](https://forum.dynamobim.com/t/extract-auto-corridor-featurelines/66225/3)

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

autoFeatureLine = IN[0]  
adoc = Application.DocumentManager.MdiActiveDocument

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

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/6/564e0a71fb8270bfc6748114d7d66522f1c7a763.png)

Any ideas?

Thanks  
A

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [May 26, 2025, 8:17am UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/2 "2025-05-26T08:17:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aa047](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@aa047](https://forum.dynamobim.com/u/aa047)\
**Post date:** [May 26, 2025, 10:53am UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/3 "2025-05-26T10:53:48Z")

</div>

ok thanks Jacob,  
Can you confirm that its possible to unwrap the corridorfeatureline to get the region name? If so how?

---

<div class="post-metadata">

**Author:** ![kovacsv](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@kovacsv](https://forum.dynamobim.com/u/kovacsv)\
**Post date:** [May 26, 2025, 10:59am UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/4 "2025-05-26T10:59:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aa047](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@aa047](https://forum.dynamobim.com/u/aa047)\
**Post date:** [May 26, 2025, 11:03am UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/5 "2025-05-26T11:03:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kovacsv](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@kovacsv](https://forum.dynamobim.com/u/kovacsv)\
**Post date:** [May 26, 2025, 11:07am UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/6 "2025-05-26T11:07:31Z")

</div>

Maybe someone more experienced than me can tell you if there are other ways to unwrap the dynamonodes feature lines directly.

Until then, maybe you can try one level lower, use the corridor object and fetch the feature lines inside the python code.

---

<div class="post-metadata">

**Author:** ![aa047](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@aa047](https://forum.dynamobim.com/u/aa047)\
**Post date:** [May 26, 2025, 11:50am UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/7 "2025-05-26T11:50:34Z")

</div>

yes thanks again, i’ll give that a go.

its driving me crazy, i though this would be a straight forward thing to do. oh well

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [May 26, 2025, 1:27pm UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/8 "2025-05-26T13:27:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aa047](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@aa047](https://forum.dynamobim.com/u/aa047)\
**Post date:** [May 26, 2025, 1:59pm UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/9 "2025-05-26T13:59:07Z")

</div>

ok, i have used the Baseline.CorridorFeatureLinesByCode node, how do i get the handle of those AutoFeatureLines?

---

<div class="post-metadata">

**Author:** ![kovacsv](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@kovacsv](https://forum.dynamobim.com/u/kovacsv)\
**Post date:** [May 26, 2025, 2:57pm UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/10 "2025-05-26T14:57:37Z")

</div>

Have you tried the Object.Handle node?

---

<div class="post-metadata">

**Author:** ![aa047](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@aa047](https://forum.dynamobim.com/u/aa047)\
**Post date:** [May 26, 2025, 3:06pm UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/11 "2025-05-26T15:06:31Z")

</div>

yes, i cant get it to work with Auto Corridor Feature Lines.

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [May 26, 2025, 4:36pm UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/12 "2025-05-26T16:36:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aa047](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@aa047](https://forum.dynamobim.com/u/aa047)\
**Post date:** [June 2, 2025, 4:56am UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/13 "2025-06-02T04:56:47Z")

</div>

Hi Jacob, I did as you said but still don’t see handle listed under dir of CorridorFeatureLine.

Do you have any other way to get the associated regions from Baseline.CorridorFeatureLines.ByCode node output (CorridorFeatureLines) ?

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 2, 2025, 6:43am UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/14 "2025-06-02T06:43:37Z")

</div>

Do you have a sample DWG? I am not a Civil 3D user so stuff like building a corridor would take me far longer than it should.

---

<div class="post-metadata">

**Author:** ![geert.drijfhout](https://avatars.discourse-cdn.com/v4/letter/g/a4c791/32.png) [@geert.drijfhout](https://forum.dynamobim.com/u/geert.drijfhout)\
**Post date:** [June 2, 2025, 7:07am UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/15 "2025-06-02T07:07:56Z")

</div>

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.

simply put `import traceback` at the top

prepare an output e..g `err = []`

along the way you use

```auto
try: 
    "your code goes here"
except:
    err.append(traceback.format_exc()

```

at the end add your err list e.g. `OUT = region, err`

Your code however gave me errors, simply returned “All”

---

<div class="post-metadata">

**Author:** ![aa047](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@aa047](https://forum.dynamobim.com/u/aa047)\
**Post date:** [June 2, 2025, 1:40pm UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/16 "2025-06-02T13:40:17Z")

</div>

Thanks Geert,

That code was originally from @mzjensen and i assume worked then and now you got the result of “All” which is correct.

Did you amend the code at all?  
What version of C3D are you using?

I still get errors with that original code.

---

<div class="post-metadata">

**Author:** ![aa047](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@aa047](https://forum.dynamobim.com/u/aa047)\
**Post date:** [June 2, 2025, 1:49pm UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/17 "2025-06-02T13:49:43Z")

</div>

I can get access to some properties through dir but still no available CorridorFeaturelineRegionName

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/a/1a3d892eb788b158b330b1fbfaebf933896f2b2e.png)

---

<div class="post-metadata">

**Author:** ![geert.drijfhout](https://avatars.discourse-cdn.com/v4/letter/g/a4c791/32.png) [@geert.drijfhout](https://forum.dynamobim.com/u/geert.drijfhout)\
**Post date:** [June 2, 2025, 2:58pm UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/18 "2025-06-02T14:58:41Z")

</div>

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:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![aa047](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@aa047](https://forum.dynamobim.com/u/aa047)\
**Post date:** [June 2, 2025, 4:00pm UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/19 "2025-06-02T16:00:23Z")

</div>

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.

Are you feeding featureline from baseline node?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/5/15b1a799e1c5465b886533b2ebf3d75f8ee53ae6.png)

---

<div class="post-metadata">

**Author:** ![geert.drijfhout](https://avatars.discourse-cdn.com/v4/letter/g/a4c791/32.png) [@geert.drijfhout](https://forum.dynamobim.com/u/geert.drijfhout)\
**Post date:** [June 3, 2025, 9:38am UTC](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379/20 "2025-06-03T09:38:02Z")

</div>

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:"

```auto
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

```

[Next page](https://forum.dynamobim.com/t/get-region-name-of-featureline/110379.md?page=2)
