Creating Walls by curves different base and top constrains

Hello there,

I am trying to create Walls in Python using a nested list with curves, baselevel, toplevel and walltype, but i dont really know how to do it properly, i searched quite a lot and hoped, that someone could help me solving it.

I want a list with the same structure, which allready worked with another output but now that he always takes the same line, baselevel and toplevel for each element. How do i do that?
Here the Code


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

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
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
# Die Eingaben für diesen Block werden in Form einer Liste in den IN-Variablen gespeichert.
TransactionManager.Instance.EnsureInTransaction(doc)

Curves =  IN[0]
Level = UnwrapElement(IN[1])
TopLevel = UnwrapElement(IN[2])
type = UnwrapElement(IN[3])
output = []
x1 = 0
x2 = 0
x3 = 0
x4 = 0
x5 = 0
# Code unterhalb dieser Linie platzieren

for i in Curves:
	list1 = []
	for u in i:
		list2 = []
		for k in u:
			list3 = []
			for p in k:
				list4 = []
				for l in p:
					list4.append(Wall.Create(doc, Curves[x1][x2][x3][x4][x5].ToRevitType() ,Level[x1][x2][x3][x4][x5], False))
					x5 = x5 + 1
				x5 = 0
				list3.append(list4)
				x4 = x4 + 1
			x4 = 0
			list2.append(list3)
			x3 = x3 + 1
		x3 = 0
		list1.append(list2)
		x2 = x2 + 1
	x2 = 0
	output.append(list1)
	x1 = x1 + 1
x1 = 0

TransactionManager.Instance.TransactionTaskDone()

# Weisen Sie Ihre Ausgabe der OUT-Variablen zu.
OUT = output>

<

It’s always useful to expand the yellow warnings so we can see what the immediate issues are. When I tried your script I got this error because the method requires the ElementId of the level, rather than the level Element itself

image

To correct this, add .Id to the level in your script:

list4.append(Wall.Create(doc, Curves[x1][x2][x3][x4][x5].ToRevitType() ,Level[x1][x2][x3][x4][x5].Id, False))

Your script doesn’t make use of the top level or wall type currently. The top level can be set by parameter after creation. The wall type can be set at creation by using

Create Method (Document, IList(Curve), ElementId, ElementId, Boolean) revitapidocs.com

Is there a reason you need to use Python for this? There is a dynamo OOTB node Wall.ByCurveAndLevels that would handle your nesting very easily and eliminate much of the complexity of your code

image

Hope this helps,
Thomas

1 Like

Thank you for the fast reply Thomas!

I think the main issue is solved. I didnt used the dynamo node because he used to create just some walls of the 320 i wanted to create, the issue is still that he doesnt build all 320 just 312, i think the levelabove node could be the problem. Anyway i tried it now with the wall.byecurveandlevels and its still nearest to a perfect solution, if i find out more i am gonna write again in this topic.

Thank you very much,

greetings,

Charles

1 Like

Sounds like a list level and lacing issue. Can you post the node version so we can help you learn that?

Hi @JacobSmall , I believe i’m having the problem you said. Since this is the same topic I’ll post it here and I’d be thankful if you could help me. My objective is to create multiple walls given a line and 2 levels. Those levels might be for example Level -1 and Level 2 and the script should create all walls between every level from -1 to 2. When I create them with the code attached in the picture, it creates 6 walls but the levels are not correct because it should be a wall per level and it creates, for each curve, 3 walls from -1 to 2, 0 to 2 and 1 to 2. So, basically it’s fixing the top level always for level 2 instead of iterating between 0,1 and 2. Can’t understand why.

Thank you in advance.