# Create corridor surface (python)

**URL:** <https://forum.dynamobim.com/t/create-corridor-surface-python/49010>\
**Category:** Civil 3D\
**Created:** [April 7, 2020, 2:40pm UTC](https://forum.dynamobim.com/t/create-corridor-surface-python/49010 "2020-04-07T14:40:53Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![keith.sowinski](https://avatars.discourse-cdn.com/v4/letter/k/d26b3c/32.png) [@keith.sowinski](https://forum.dynamobim.com/u/keith.sowinski)\
**Post date:** [April 7, 2020, 2:40pm UTC](https://forum.dynamobim.com/t/create-corridor-surface-python/49010/1 "2020-04-07T14:40:53Z")

</div>

I don’t know how to code using python (or much of anything else), but I’m trying to use the python node as a way to create corridor surfaces. I’ve tried to use various sample scripts found on this forum as a guide, but I’m coming up short. Can someone please review my code to get me back on track? It will create a single corridor surface, but there are three remaining issues:  
[CreateCorridorSurface.dyn](https://forum.dynamobim.com/uploads/short-url/5V5G9R9p16GcuM5hEHnrokC9G5z.dyn) (6.3 KB)

1. I cannot get it to create multiple corridor surfaces given a list of names
2. I’m getting a TypeError: “expected str, got CorridorSurface”
3. The surface that get’s created is not activated in the Corridor properties.  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/a/eaf76f588201cb3a4b0c92347e7f2a406077f377.png)

---

<div class="post-metadata">

**Author:** ![keith.sowinski](https://avatars.discourse-cdn.com/v4/letter/k/d26b3c/32.png) [@keith.sowinski](https://forum.dynamobim.com/u/keith.sowinski)\
**Post date:** [April 7, 2020, 3:18pm UTC](https://forum.dynamobim.com/t/create-corridor-surface-python/49010/2 "2020-04-07T15:18:48Z")

</div>

I resolved all three of these issues, but created a new one. I need the output to be a list of the created surfaces. It’s successfully creating the surfaces, but I get an empty list on the output.

```
def create_corridor_surfaces(names):
    """
    This method demonstrates how to create corridor surfaces from an existing corridor.
    :param names: List of corridor surface names to create
    :return: A list of corridor surface names
    """
    global adoc
    global ed
    global civdoc
    
    if names is None:
    	return
    	
    if not isinstance(names, list):
    	names = [names]
    	
    result = []
    
    try:
        # Get the active document in the AutoCAD session:
        with adoc.LockDocument():
            with adoc.Database as db:
                with db.TransactionManager.StartTransaction() as t:
                    # Ask the user to select a corridor to create a new corridor surface from
                    opt = PromptEntityOptions('\nSelect a Corridor')
                    opt.SetRejectMessage('\nObject must be Corridor.')
                    opt.AddAllowedClass(Corridor, False)

                    corid = ed.GetEntity(opt).ObjectId

                    cor = t.GetObject(corid, OpenMode.ForRead)

                    # Creates a new surface
                    for n in names:
                    	cor.CorridorSurfaces.Add(n)

                    t.Commit()
    except Exception() as ex:
        MessageBox.Show(ex.message)
    return result
	
	
OUT = create_corridor_surfaces(IN[0])
```

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [April 7, 2020, 3:30pm UTC](https://forum.dynamobim.com/t/create-corridor-surface-python/49010/3 "2020-04-07T15:30:25Z")

</div>

Hi @keith.sowinski

```
result.append( cor)
return result
```

---

<div class="post-metadata">

**Author:** ![keith.sowinski](https://avatars.discourse-cdn.com/v4/letter/k/d26b3c/32.png) [@keith.sowinski](https://forum.dynamobim.com/u/keith.sowinski)\
**Post date:** [April 7, 2020, 3:39pm UTC](https://forum.dynamobim.com/t/create-corridor-surface-python/49010/4 "2020-04-07T15:39:43Z")

</div>

Thank you. That gives me the output of

Autodesk.Civil.DatabaseServices.Corridor.

I tried  
`result.append(cor.CorridorSurfaces.Add(n))`  
and that gives me an output of  
Autodesk.Civil.DatabaseServices.CorridorSurface

I thought that would work for me, but I can’t seem to do anything with that output. For instance, The CivilObject.Name node returns and error.

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

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [April 7, 2020, 3:59pm UTC](https://forum.dynamobim.com/t/create-corridor-surface-python/49010/5 "2020-04-07T15:59:22Z")

</div>

> [@keith.sowinski](#):
>
> but I can’t seem to do anything with that output.

What do you need output?

---

<div class="post-metadata">

**Author:** ![keith.sowinski](https://avatars.discourse-cdn.com/v4/letter/k/d26b3c/32.png) [@keith.sowinski](https://forum.dynamobim.com/u/keith.sowinski)\
**Post date:** [April 7, 2020, 4:12pm UTC](https://forum.dynamobim.com/t/create-corridor-surface-python/49010/6 "2020-04-07T16:12:05Z")

</div>

The surface. Then I hoping to do other things to it like add feature lines to its definition, change it’s style, etc.

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [April 7, 2020, 5:56pm UTC](https://forum.dynamobim.com/t/create-corridor-surface-python/49010/7 "2020-04-07T17:56:40Z")

</div>

> [@keith.sowinski](#):
>
> The surface.

This should solve your problem:

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

---

<div class="post-metadata">

**Author:** ![keith.sowinski](https://avatars.discourse-cdn.com/v4/letter/k/d26b3c/32.png) [@keith.sowinski](https://forum.dynamobim.com/u/keith.sowinski)\
**Post date:** [April 7, 2020, 7:14pm UTC](https://forum.dynamobim.com/t/create-corridor-surface-python/49010/8 "2020-04-07T19:14:50Z")

</div>

Thank you for your help. One more thing I’d like to do with this python node.

Currently, the corridor selection is done with the python script.

```
               opt = PromptEntityOptions('\nSelect a Corridor')
                opt.SetRejectMessage('\nObject must be Corridor.')
                opt.AddAllowedClass(Corridor, False)

                corid = ed.GetEntity(opt).ObjectId

                cor = t.GetObject(corid, OpenMode.ForRead)

```

However, I would prefer to select the corridor using the Select Object node. I would prefer to select the corridor this way so it listed in Dynamo player next to the rest of the inputs.  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/6/4620e219d5d93c994c8cd2a9a3166662a49e64fd.png)

How can I massage this python script to select the corridor in this way?

---

<div class="post-metadata">

**Author:** ![keith.sowinski](https://avatars.discourse-cdn.com/v4/letter/k/d26b3c/32.png) [@keith.sowinski](https://forum.dynamobim.com/u/keith.sowinski)\
**Post date:** [April 7, 2020, 7:40pm UTC](https://forum.dynamobim.com/t/create-corridor-surface-python/49010/9 "2020-04-07T19:40:57Z")

</div>

I found this nugget in the developers guide. Seems to be working.

`corid = civdoc.CorridorCollection[corridorName]`

---

<div class="post-metadata">

**Author:** ![ozanunsal](https://avatars.discourse-cdn.com/v4/letter/o/f9ae1b/32.png) [@ozanunsal](https://forum.dynamobim.com/u/ozanunsal)\
**Post date:** [June 14, 2022, 7:54pm UTC](https://forum.dynamobim.com/t/create-corridor-surface-python/49010/10 "2022-06-14T19:54:06Z")

</div>

Hi Keith,  
Would you share the last dyn file please?  
I made the corrections but I can’t be able to run it. ☹

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [June 14, 2022, 8:42pm UTC](https://forum.dynamobim.com/t/create-corridor-surface-python/49010/11 "2022-06-14T20:42:24Z")

</div>

@ozanunsal if you’re interested in a non-Python solution, there are nodes for Corridor surfaces in the Camber package.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/4/d4f58f1c481ab13c77fde53fe302eca3f1849228.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/a/2a15a4a29afc85f6ff7d427a3fb99497534071ca.png)

---

<div class="post-metadata">

**Author:** ![ozanunsal](https://avatars.discourse-cdn.com/v4/letter/o/f9ae1b/32.png) [@ozanunsal](https://forum.dynamobim.com/u/ozanunsal)\
**Post date:** [June 14, 2022, 9:57pm UTC](https://forum.dynamobim.com/t/create-corridor-surface-python/49010/12 "2022-06-14T21:57:28Z")

</div>

Thank you for your time and reply.

I downloaded the package but it throws  
“Could not load type ‘ExportableItem’ from assembly ‘AeccDataShortcutMgd, Version=13.4.214.0, Culture=neutral, PublicKeyToken=null’.”

Is this something related with Phyton libraries are not installed or is my Dynamo version old or am I just cooking up? 🙂 😇

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [June 14, 2022, 11:38pm UTC](https://forum.dynamobim.com/t/create-corridor-surface-python/49010/13 "2022-06-14T23:38:08Z")

</div>

It is the version of Civil 3D that you are using. If you’re on 2021, please upgrade to 2021.3. If you’re on 2022, please upgrade to 2022.1 or later.
