DynamoRevit + Python References

Good Afternoon All,

I am trying to learn how to use Python to open up the doors of possibilities myself rather than purely relying on other individuals to update their amazing node packages.

I have started to learn the basic functions of python which i think will sink in over time…

The main confusion i have is with the references and how anyone is meant to comprehend all possible functions of each reference.

So i realised that the following code would open up access to the revitapi

import clr
clr.AddReference(“RevitAPI”)
from Autodesk.Revit.DB import*

Thankfully there is a website supporting this (https://www.revitapidocs.com/)
Therefore i am able to start understanding how the coding is used to reference each part of the “RevitAPI”.

However, there is nothing like this for other references such as “RevitServices” and “RevitNodes”?
I have tried to open the dll files for each but clearly don’t have the right programs for that as it’s far from readable.

A couple questions in relation to the “RevitNodes”.
part of importing Revit.elements (for example) is written as

clr.ImportExtensions(Revit.Elements)

Is that just how you import functions within a subfolder of the main library folder?

ie you could also:
clr.ImportExtensions(Revit.GeometryObjects) ?

I also realise that you can call dll’s such as Protogeometry which is not part of the DynamoRevit library but instead is part of the DynamoCore library.

This is still referenced with clr.Addreference though.

I also know that certain other .dll’s have to be called by literally specifying the file path.

Long story short, are there any helpful links out there to help someone who is trying to learn all of the available Clr References etc and how to actually reference each one as i know it’s not always the same?

I have searched the forum and found older similar posts but i’m hoping the answer is a little different now. I just don’t understand how people are able to figure out which references to add (assuming they’re not familar with them already). Then how do people figure out which classes of each namespace to call and what that class can achieve etc?

As a final query, i’d like to get my terminology corrected (namespaces / classes / methods etc. Anyone got a simple way of explaining it (maybe visually) ?

Any help is always appreciated.
I’m just trying to move away from “seach dynamobim website for similar code, adapt it to what i want” and move to “write the python code myself and use OOTB nodes if nessesary to fill in the gaps / complete the workflow”

Thanks!

1 Like

Just found this which looks pretty useful for use of the RevitAPI!

Anything else like this would be very helpful. Thanks!

Is it maybe also worth using a different editor rather than the default Dynamo Python Script Editor?

2 Likes

There is a github page that shows some examples with annotation to help guide people about what it is doing, you can find them at the below link.

This github page was created by Sol Amour with contributions from other people from the community including me.

2 Likes

@Brendan_Cassidy Thankyou. I will check this out. At first glance it looks very useful!

There’s also a forum post here…

Hopefully that’s of interest.

Mark

Mark Thankyou!

1 Like

Hi @luckysurfcs!

I am exactly at the same point as you 2 years ago. I do not imagine how your learning on Revit-Python goes but some of the answers to your question were found in the book " MAS ALLA DE DYNAMO: MANUAL DE PYTHON PARA REVIT" by Kevin Himmelreich. I know is in Spanish but it is worth having a look.
Hopefully, we can have a chat later and exchange ideas about this exciting environment of BIM-Revit-Dynamo-Python-Automation.