hi everyone, I’m trying to create a wall by python script but it shows some error please guide me.
"
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
"
Hey,
If you wouldn’t mind hitting 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?
Here’s a bit of working code for you to look at…
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
1 Like
thanks, @Mark.Ackerley
this is my graph
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?
i did 5000mm but it shows same error, how to add formatting??
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
4 Likes
wow its working thanks @Alban