Wall by python script

python
#1

hi everyone, I’m trying to create a wall by python script but it shows some error please guide me.

image

"
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
"

0 Likes

#2

Hey,

If you wouldn’t mind hitting image 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…

Hope that helps,

Mark

1 Like

#3

thanks, @Mark.Ackerley
this is my graph

0 Likes

#4

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?

0 Likes

#5

i did 5000mm but it shows same error, how to add formatting??

0 Likes

#6

Edit and click image

0 Likes

#7

image

0 Likes

#8

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
3 Likes

#9

wow its working thanks :grinning: @Alban

0 Likes