Revit Dynamo Python Error

Howdy,
I have been trying to write something to create sheets and place views on them. In my search for pieces I came across a youtube video that shared a script with custom nodes in them. I have recreated the python portions of it but I am getting some error messages that I do not understand. See below screen grabs. In googling these, I came across some Iron Python vs Python issues. I have followed all the steps in the GitHub blog post to remedy those. I am thinking maybe there is another issue in here somewhere. This is my first attempt with Python so I am not that great at reading or understanding it yet. Sorry if it is obvious. Both of these yellow nodes have the same errors. I can only post one image so I linked to the images below.

The lib you might want to load is clr.AddReference(‘RevitAPI’)
not
clr.AddReference(‘Revit API’)

1 Like

Whelp, that helped it to run past line 4 but now its giving me a different error message on each of them. I have pasted the two node text bodies below if that helps. I am not sure what the errors mean. Error message images are here:


Make Sheets

import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
sheets = IN[0]
views = IN[1]
x = IN[2]
y = IN[3]
viewsplaced = list()

TransactionManager.Instance.EnsureInTransaction(doc) # you need an active transaction as you will create elements

for Number in range(len(sheets)):
sheet = UnwrapElement(sheets[number])
view = UnwrapElement(views[number])
Viewport.Create(doc,sheet.Id,view.Id,XYZ(x,y,0))
Viewsplaced.append(view.ToDSType(False))

TransactionManager.Instance.TransactionTaskDone()
OUT = viewsplaced


Make Sheets

import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
sheets = IN[0]
views = IN[1]
x = IN[2]
y = IN[3]
viewsplaced = list()

TransactionManager.Instance.EnsureInTransaction(doc) # you need an active transaction as you will create elements

for Number in range(len(sheets)):
sheet = UnwrapElement(sheets[number])
view = UnwrapElement(views[number])
Viewport.Create(doc,sheet.Id,view.Id,XYZ(x,y,0))
Viewsplaced.append(view.ToDSType(False))

TransactionManager.Instance.TransactionTaskDone()
OUT = viewsplaced


The error implies that you aren’t capitalizing your booleans (True, False), but your code doesn’t show that, so I’m not entirely sure of what’s going on.

You use “Number” in the for, but [number] in the code. Verify all your capitalization for variables.

4 Likes

I had two other capitalization errors in the python. Thanks so much everyone! works great now!