I’m trying to create a wall using Pythonscript and revit api, but I don’t know how. Please help me.
You have an error in the level input line
It should be
level = UnwrapElement(IN)
0 not 1 judging from your node setup
actually your node inputs don’t match ones in code - you should start with fixing that…
You can try a script like this:
import clr clr.AddReference("RevitServices") from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager clr.AddReference("RevitAPI") from Autodesk.Revit.DB import Wall clr.AddReference("RevitNodes") import Revit clr.ImportExtensions(Revit.GeometryConversion) #The inputs to this node will be stored as a list in the IN variables. level = UnwrapElement(IN) lines = UnwrapElement(IN) doc = DocumentManager.Instance.CurrentDBDocument TransactionManager.Instance.EnsureInTransaction(doc) walls =  for l in lines: w = Wall.Create(doc, l.ToRevitType(), level.Id, False) walls.append(w) TransactionManager.Instance.TransactionTaskDone() #Assign your output to the OUT variable. OUT = walls
Sorry, I uploaded the wrong image. Image modified.
One more time please.
python function len(something) gives you an integer length of ‘something’. You cannot iterate over integer - that is your error in yellow. To do an indexed iteration like so check the ‘range’ function in python…However there is no need to use indices - check my answer above (the one with code).
Thank you, it was very helpful :>
I have one more question.
Can I create walls without using curves and wall types?
Thank you for your kind answer.
I believe there is no function in RevitAPI that creates wall without specifying a location curve.
As for the type - it is not a wall type. This conversion is necessary because Dynamo objects are not Revit objects. So in order to pass a curve as a parameter to Revit API function it has to be converted from Dynamo-kind curve into Revit-kind curve.
In your Script there is a conflict ‘Wall’s Class’ between 2 Namespaces
from Autodesk.Revit.DB import Wall
from Revit.Elements import *
one solution is to assign the Revit class Wall to an alias (example RvtWall)
import clr clr.AddReference('RevitServices') import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager #import Revit API clr.AddReference('RevitAPI') from Autodesk.Revit.DB import Wall as RvtWall clr.AddReference('RevitNodes') import Revit from Revit.Elements import * clr.ImportExtensions(Revit.Elements) clr.ImportExtensions(Revit.GeometryConversion) doc = DocumentManager.Instance.CurrentDBDocument level = UnwrapElement(IN) lines = UnwrapElement(IN) walls =  TransactionManager.Instance.EnsureInTransaction(doc) for l in lines: w = RvtWall.Create(doc, l.ToRevitType(), level.Id, False) walls.append(w) TransactionManager.Instance.TransactionTaskDone() OUT = walls
It is way easier just to remove the line that brings confusion and is unneccessary
In general it is best practice not to use ‘*’ on imports and import only stuff you need.