Neccesary headers in a Revit Python script

I’am new to writing (Revit related) Python Script in Dynamo.

And i’am wondering what kind of headers (modules / libraries) are neccesary when getting data from Revit elements. I started with a Clockwork Node as a reference. And it used the following as a header:

import clr
from Autodesk.Revit.DB import *

import Revit

(e.g. Element.ID+)

But the script also works without this header and that seems strange to me.
So is it still neccesary to add this kind of header when getting data from revit elements?

Perhaps these libraries and modules are also beeing loaded without explicitly calling them?
Or is this behavior not intended and less stable.

Just try:

items = UnwrapElement(IN[0])
elementlist = list()
for item in items:
OUT = elementlist

Take a look here -

Thanks for the feedback. I found the Dynamoprimer.

Still the question remains, because the Dynamoprimer doesn’t explain why my script without the header (imported modules / libraries) still works. It shouldn’t be working.

I would like to know if adding this header still is neccesary.
Perhaps it is already loaded while opening Dynamo in Revit ??

Using the ‘UnwrapElement’ method you will be able to access the members of the Revit API, that’s why it still works even without the headers. If you want to do some more advanced stuff in your Python code then you will need all those extra imports. I guess most package creators (myself included) usually use a template or copy/paste the import lines because most of the time you actually do need them.

1 Like

Thanks Taco

1 Like