Create a Wall by profile | Python + Dynamo

Hi everyone!

I’m trying to create a wall using a curves like profile. But I got a Exception " Failed to create the wall"

If you can help me, I’ll appreciate you.
Thanks.

import clr 
import sys 
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib') 
import System 
from System import Array 
from System.Collections.Generic import * 
clr.AddReference('ProtoGeometry')  
from Autodesk.DesignScript.Geometry import * 
clr.AddReference("RevitNodes")
import Revit 
clr.ImportExtensions(Revit.Elements) 
clr.ImportExtensions(Revit.GeometryConversion) 
from Revit import GeometryConversion 
clr.AddReference("RevitServices")
import RevitServices 
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager 
clr.AddReference("RevitAPI") 
clr.AddReference("RevitAPIUI")

import Autodesk 
from Autodesk.Revit.DB import * 
from Autodesk.Revit.UI import *   

doc = DocumentManager.Instance.CurrentDBDocument 
uiapp = DocumentManager.Instance.CurrentUIApplication 
app = uiapp.Application  
uidoc = uiapp.ActiveUIDocument 

Curves = IN[0]



		
TransactionManager.Instance.EnsureInTransaction(doc)

RVTCurves=[]
for i in Curves:
	A=[]
	RVTCurves.append(A)
	for j in i:
		A.append((j.ToRevitType()))
walls=[]
for i in RVTCurves:
	walls.append(Wall.Create(doc,i,True))
#wall=Wall.Create(doc,RVTCurves,True)

TransactionManager.Instance.TransactionTaskDone()



OUT =  walls

without seeing the curves (and verifying if they are closed or not), it is hard to know why this exception is raised.

Also the hierarchy of lists is not clear from what you have provided. You iterated over Curves[0], how many curves are in this list? how is it different from Curves list?

Also, I have had issues with using IronPython lists instead of .NET ILists. I would recommend creating an IList as you iterate over the curves:

from System.Collections.Generic import List
lst = List[Curve]()
lst.Add(curve_instance)
1 Like

Sorry, my bad
I updated the image.
I’m using 2 list to create 2 walls by profile.

Hello @niojuri22
in addition to @habdirad 's remarks there is an error in the 1st loop (you add empty lists in the RVTCurves list )
another note if your script only creates walls you don’t need all these imports

1 Like

Your first loop is completely wrong. You create for every step an empty “A” and append to RVTCurves list.

Thanks for all
I already solved!