Wall by profile in Python code doesn't work anymore using Dynamo 2.0.3 in stead of 1.3.3

Hi Guys,

I’m new here and i have a question about python in Revit. I’m trying to make a Wall by profile using Python. This is the code i’m using:

import clr

clr.AddReference(“RevitNodes”)

import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

from System.Collections.Generic import List as Lst

clr.AddReference(‘RevitApi’)
from Autodesk.Revit.DB import Wall, Curve

doc = DocumentManager.Instance.CurrentDBDocument

curves = IN[0]
levels = IN[1]
types = IN[2]

walls = []
index = 0

TransactionManager.Instance.EnsureInTransaction(doc)

# Validatie
# if (validatie not ok)
# show error
# else

for curve in curves:
** for loop in curve:**
** profile = LstCurve**
** for i in loop:**
** profile.Add(i.ToRevitType())**
** wall = Wall.Create(doc, profile, UnwrapElement(types[index]).Id, UnwrapElement(levels[index]).Id, False)**
** walls.append(wall)**
** index = index + 1**

TransactionManager.Instance.TransactionTaskDone()

OUT = walls

I didn’t write it myself: a collegue found it somewere online. In Revit 2018/Dynamo 1.3.3 the code worked fine, but using Revit 2019/Dynamo 2.0.3 i can’t get it to work.

Ik keep getting this error:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. **
Traceback (most recent call last):
** File “”, line 38, in

TypeError: iteration over non-sequence of type Curve

Can someone please help me? I’m a little bit lost here!

I apologize for my Eglish, it’s not my native language… sorry!

Thank you in advance!

1 Like

Can you please share your inputs and desired result?

What is happening is the input for your “curves” variable is not in the list structure that the code was intended for.

Hi Ericabbott,

This is the input:

If i try this:

the code also doesn’t work

I have modified your script and it is working for me.

Dynamo Graph:

Python Code:

Result:

Please let me know if this works for you or if you are still having trouble.

1 Like

Wow!!!

You are my hero!!!

Its working! Thank you so much!!

No problem. Glad I could help!

Keep in mind this script will only work for one wall at a time as is.

I’m trying to make several walls at the same time. Do you know a way I can modify the code so I have a list with levels, walltypes and ofcourse curves in a nested list?

Something like this:

Sure. Here you go.

Dynamo Graph:

Python Script:

Result:
image

Thank you so much for your help and time!! I really appreciate it!

Unfortunately I get a Warning:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 33, in
NameError: name ‘types’ is not defined

Do you see what I did wrong?

Yes, easy fix. I changed variable names in the new script.

Change “level” to “levels” on line 23, and “type” to “types” on line 24.

hmm… still the same error…:face_with_raised_eyebrow:

image

Can you post a screenshot of the error? You have defined “types” now so you shouldn’t be getting that same error.

I also adjusted OUT = wall into OUT = walls

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 33, in
AttributeError: ‘str’ object has no attribute ‘Id’

Sorry, different warning this time!

I believe this warning is because your wall type input is a list of strings instead of wall type elements.

Try implementing the WallType.ByName node to your graph.

Thank you! You were absolutely right!
You helped me so much! I’v been working on this for several days without result…

You really are my Hero!

Glad to help. Have a great day!

1 Like

Got Following Error.

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 33, in
Exception: Failed to create the wall.

How to Resolve it!

scrip image !