About import clr, import Revit etc in Python

Dear colleague’s,

I have a question about the first thing one types in every python script, namely import clr , import Revit etc. Why import in each python script different things every single time instead of import everything at once and copy that every time you make a new python script? Dose it have anything to do with performance? Is it even possible to import everything at once?

The more you import, the more you have to load. This impacts speed, but also… The more you load, the more the code needs to collaborate with itself. This means that you’r emore likely to have multiple functions with the same name - say point which exists in Dynamo and Revit and AutoCAD, and… a lot of stuff. This requires you to explicity call out which library you want to pull the function from, which takes more time to write and more time to load.

Yes, but it’ll cost you. Imagine if the first thing you did when starting a Revit project to load in every family and type in your library. The file would be disastrous to work with. The same applies with code.

1 Like

Okay then. Only load what you need. Thanks!

1 Like