I need help! I don’t understand warning by python. I want create a new dimensions on lines. If I using one level lists, all OK. But if I using one more level, the python issues a warning. What is problem?
This python script
This is all script in dynamo
This is lines in Revit.
Because multi level lists are a list of lists of a type (In your case a list of lists of type line). If you’re expecting a list of lists then handle it in code like you have for your elements. Otherwise you could rely upon lacing (which is only available after you have packaged your python node into a custom node) or you could flatten before you input into the python node ( which is not always the best solution if you need the levels). Also, you can choose the level manually, but again after you have packaged into a custom node.
But i have. in pyhton code, double circles for second level.
Ah, I see. Yup, you’re right. I think the problem is that you are passing in more than one line for the NewDimension() method.
This takes a view, a line, and references.
See the Revit API docs…
You need to zip loop through the linelist and elementsref lists and then use the method…
It will look something like this…
for l, r in zip(linelist,elementsRef):
…newDim = doc.Create.NewDimension(view,l,r)
And you want to keep the Element refs in their arrays…
for elementlist in elements:
.,.,.arr = 
.,.,.for e in elementlist:
(Apologies for the lack of formatting, I am on a mobile)
Let me know how you get on.
It is correct?
I have a warning:
File “”, line 57, in
TypeError: expected ReferenceArray, got list
Yup, sorry… You need to make sure you create a reference array to store the references. Here is the full working code…
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
from Autodesk.Revit.DB import *
if hasattr(obj1,"__iter__"): return obj1
else: return [obj1]
view = tolist(UnwrapElement(IN))
dimLines = tolist(UnwrapElement(IN))
linesToDim = tolist(UnwrapElement(IN))
refArrays = 
outList = 
for lineList in linesToDim:
rArr = ReferenceArray()
for l in lineList:
for l,r in zip(dimLines,refArrays):
OUT = outList
This should work for you. Easier now I have a pc with a monitor!
Thank you so much!!! All work!))
But tell me, why are you using “def” and “try, except”? I am newbie in python and this is interesting for me
def is for definition. This definition ensure that when i bring in IN data, that it is always in a list. So if it is just one item, it will make sure this is a list of one item. That way i don’t get errors if looping.
Try/Except are cases for trying to do something and handling/reporting errors. for example…
…if “Do Something failed” then do something else… or continue.
Hope that makes sense. It’s always good to error catch early. Try use these in your code whenever you think something could fail.