# Wall by python script

**URL:** <https://forum.dynamobim.com/t/wall-by-python-script/31488>\
**Category:** Revit\
**Tags:** python\
**Created:** [January 31, 2019, 11:56am UTC](https://forum.dynamobim.com/t/wall-by-python-script/31488 "2019-01-31T11:56:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![thiru2jack](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thiru2jack/32/112308_2.png) [@thiru2jack](https://forum.dynamobim.com/u/thiru2jack)\
**Post date:** [January 31, 2019, 11:56am UTC](https://forum.dynamobim.com/t/wall-by-python-script/31488/1 "2019-01-31T11:56:33Z")

</div>

hi everyone, I’m trying to create a wall by python script but it shows some error please guide me.

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

"  
import clr  
clr.AddReference(“RevitServices”)  
import RevitServices  
from RevitServices.Persistence import DocumentManager  
from RevitServices.Transactions import TransactionManager  
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference("RevitAPI")  
import Autodesk  
from Autodesk.Revit.DB import \*

clr.AddReference("RevitNodes")  
import Revit  
clr.ImportExtensions(Revit.Elements)  
clr.ImportExtensions(Revit.GeometryConversion)

#clr.AddReference(‘ProtoGeometry’)  
#from Autodesk.DesignScript.Geometry import \*

if isinstance(IN[0], list):  
lines = IN[0]  
else:  
lines = [IN[0]]

level = UnwrapElement(IN[1])  
type = UnwrapElement(IN[2])  
Struc = IN[3]  
TransactionManager.Instance.EnsureInTransaction(doc)  
ele =

for i in lines:  
wall = Wall.Create(doc,lines,type.Id,level.Id,Struc)

ele.append(wall)

TransactionManager.Instance.TransactionTaskDone()  
OUT = wall  
"

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [January 31, 2019, 12:46pm UTC](https://forum.dynamobim.com/t/wall-by-python-script/31488/2 "2019-01-31T12:46:07Z")

</div>

Hey,

If you wouldn’t mind hitting ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/9/59603404d39206337990e491428ce4faa756f130.png) when you paste code it will keep the formatting.

If you’re pasting code with inputs, then we’ll want to see the dynamo graph to check that your inputs are what they should be. Right now you have Struct coming IN[3] that should be a boolean, but perhaps you are feeding something else?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/4/94033d9d45a73af4e06d0cf89a89f4eadbedec12.png)

Here’s a bit of working code for you to look at…

> [@Trying to create wall by levels using python](https://forum.dynamobim.com/t/trying-to-create-wall-by-levels-using-python/31149/2):
>
> Hey, This works for me… There were things that were right and a few things to change, I would look at the Clockwork and Archi-lab nodes to see how they are working. Hope that helps, Mark P.S. when pasting code, please use [image] to format it #thanks to clockwork and Archi-lab import clr clr.AddReference('RevitNodes') import Revit clr.ImportExtensions(Revit.Elements) clr.AddReference('RevitServices') import RevitServices from RevitServices.Persistence import DocumentManager from RevitS…

Hope that helps,

Mark

---

<div class="post-metadata">

**Author:** ![thiru2jack](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thiru2jack/32/112308_2.png) [@thiru2jack](https://forum.dynamobim.com/u/thiru2jack)\
**Post date:** [January 31, 2019, 12:55pm UTC](https://forum.dynamobim.com/t/wall-by-python-script/31488/3 "2019-01-31T12:55:38Z")

</div>

thanks, @Mark.Ackerley  
this is my graph

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

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [January 31, 2019, 12:57pm UTC](https://forum.dynamobim.com/t/wall-by-python-script/31488/4 "2019-01-31T12:57:59Z")

</div>

No worries, thanks.

If you could edit your code to add formatting it will help…

Right now you’re feeding a 5mm long line to create a 300mm wide wall?

Maybe that’s the problem?

---

<div class="post-metadata">

**Author:** ![thiru2jack](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thiru2jack/32/112308_2.png) [@thiru2jack](https://forum.dynamobim.com/u/thiru2jack)\
**Post date:** [January 31, 2019, 1:05pm UTC](https://forum.dynamobim.com/t/wall-by-python-script/31488/5 "2019-01-31T13:05:05Z")

</div>

i did 5000mm but it shows same error, how to add formatting??

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [January 31, 2019, 1:10pm UTC](https://forum.dynamobim.com/t/wall-by-python-script/31488/6 "2019-01-31T13:10:11Z")

</div>

Edit and click ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/9/59603404d39206337990e491428ce4faa756f130.png)

---

<div class="post-metadata">

**Author:** ![thiru2jack](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thiru2jack/32/112308_2.png) [@thiru2jack](https://forum.dynamobim.com/u/thiru2jack)\
**Post date:** [January 31, 2019, 1:20pm UTC](https://forum.dynamobim.com/t/wall-by-python-script/31488/7 "2019-01-31T13:20:24Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/9/c9f87f71859c632721329ec183339d9b85d71a9c.png)

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

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [January 31, 2019, 1:22pm UTC](https://forum.dynamobim.com/t/wall-by-python-script/31488/8 "2019-01-31T13:22:09Z")

</div>

Hi,

You need to convert your dynamo curve in Revit curve (ToRevitType()) and the method you use is for walls per profile:

```
import clr
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

if isinstance(IN[0], list):
	lines = IN[0]
else:
	lines = [IN[0]]

level = UnwrapElement(IN[1])
type = UnwrapElement(IN[2])
Struc = IN[3]
ele= []

TransactionManager.Instance.EnsureInTransaction(doc)
for i in lines:
	wall = Wall.Create(doc,i.ToRevitType(),level.Id,Struc)
	wall.ChangeTypeId(type.Id)
	ele.append(wall)	
TransactionManager.Instance.TransactionTaskDone()

OUT = wall
```

---

<div class="post-metadata">

**Author:** ![thiru2jack](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thiru2jack/32/112308_2.png) [@thiru2jack](https://forum.dynamobim.com/u/thiru2jack)\
**Post date:** [January 31, 2019, 1:24pm UTC](https://forum.dynamobim.com/t/wall-by-python-script/31488/9 "2019-01-31T13:24:10Z")

</div>

wow its working thanks 😀 @Alban
