I am starting to learn dynamo python through Primer. I am interested to know which of these two APIs I should concentrate on? Revit or Dynamo API? I would prefer concentrating on a single one, instead of both.
As I understood, Dynamo can also access Revit API (through UnwrapElement(IN[0])).
Learning Revit API can one day help in case I want to switch to Revit plugins, instead of using Dynamo.
But I see that Dynamo on the other hand is quite fast and powerful, and can achieve results in a matter of minutes, which is not the case with plugins.
Are there some opinions on which of these two APIs are more beneficial? The pros and cons?
Which one has more online examples?
What about documentation? Is there an online/offline Dynamo API alternative similar to revitapidocs?
Are there some important functionalities which Revit API has - and Dynamo API does not, and vice-versa?
youâll effectively be learning both at the same time. Understanding what to do with dynamo nodes requires understanding the API, and eventually youâll want to do something thatâs easier to execute with a direct API call via Python (so youâre really learning 3 things)
But you can get pretty far with just dynamo nodes and designscript.
First learn how the nodes work directly, then transition into Design Script as itâs a great starter language for coding, and then move into Python (focusing on Python 3 as most of the Python 2 stuff is no longer necessary) and the relevant APIs (Both Dynamo and Revit as your will need both).
I agree about learning standard dynamo nodes, but is learning Designscript that necessary? I would rather skip it, and go straight with the dynamo python.
I am familiar with python v2, and I donât think the transition to python v3 (source, source2) will be that painful, as I am already using all the concepts mentioned in the âsourceâ.
Where can I find API documentation for Dynamo (not Revit) classes, methods?
I found this:
I would recommend learning to use the inspect module in Python for much of this.
However the best way to learn this will be via DesignScript, as the node to code function will help you learn the notation, and those notations are pretty much 1-1 into Python.
Ah, I see. I donât think there is such API docs other than dynamo itself and Dynamo Dictionary. You could again always look on the Dynamo Revit GithubâŚ
But I think I understand what you mean in your initial question a bit better. I would recommend the followingâŚ
For anyone new to Programming/Dynamo, learn dynamo first as it will really boost your understanding of how programming works.
For anyone comfortable with Dynamo but new to programming/python. Start with converting your graph to code. This is pretty easy and can be done with any built-in node. As for Revit, I would start with Dynamo Revit and not pure Revit API, again, itâs easier to convert which gives a shallower learning curve than jumping straight into the Revit API.
For anyone that is comfortable with both python/programming and dynamo. Then jump straight into the Revit API. The Revit API has lots that Dynamo doesnât have, particularly when you are using it in Plugins, so using dynamo as a sandbox is a good way to learn initially and also debug later.
Hi @Daniel_Woodcock1 ,
Thank you for the reply.
I see that link contains C# source code of the Dynamo itself.
I am stunned that after more than 6 years of its existence, Autodesk to this day does not have Dynamo API documentation.
I didnât understand you this part:
If I am converting the graph to code, why do I need the built-in nodes? They are Dynamo standard nodes, thus not code nodes? Forgive me if I understood you incorrectly.
Hi @jacob.small ,
Thank you for the reply. too. inspect module does not work on majority of Dynamo objects in IronPython2. Here is an example of its main getmembers function, and an error it produces:
Iâm still not entirely sure what you are after. You used CurtainPanel.Boundaries as an example, but this is documented in the dynamo library view by going to Revit > Elements > Curtain Panel > boundaries. Or documented on the Dynamo dictionary siteâŚ
This returns a polycurve in which you can again just use either Dynamo App library to find what members this object has or again just use dynamo dictionary.
All public members for ds types have some degree of documentation. Is there a specific case where you donât have documentation?
As for your question, why do you need the Built in nodes, well the built in nodes are the Dynamo Revit API (which is a limited wrapper around the Revit API which extends the Revit API in places or simply exposing it within a DS friendly context). As you said, the Revit API Panel doesnât have this member called boundaries and in this case you may choose to save yourself some time writing the python code to get the boundaries and instead converting to DS object and then using OOTB CurtainPanel.Boundaries function. If you donât want to use the built in nodes, then just use the Revit API directly which is also well documented. NOTE: If you are looking to write Plugins, then you also wonât be able to use the Dynamo OOTB nodes, so if you rely on functionality of a node (in graph or in code), you will need to write your own equivalent function from scratch or convert C# version to python in your own code.
Thank you for the patience and helpful replies, once again @Daniel_Woodcock1
That makes it more clear for me now.
What I was hopping is that Dynamo API documentation has already been released, in the similar form to any other API documentation, or at least close to that. For example, this is the screenshot of the Revit APIâs âPanelâ class from the âRevitAPI.chmâ SDK documentation shipped with Revit installation:
It clearly shows all the methods and properties of the âPanelâ class.
In Dynamoâs case, due to non-existence of the API documentation, I donât know which other methods or properties exist for the âCurtainPanelâ class, because both Dynamo Library and Dynamo Dictionary show only 10 in total:
So what I would have to go to Dynamo Library/Dictionary: Revit â Elements â Element, and check which methods and properties are there, in order to know which additional ones are available for the âCurtainPanelâ class (because âCurtainPanelâ inherits from âElementâ class).
This is all very tedious, but I guess without the Dynamo API, there is no other way.
Thank you for the clarification on this as well.
The sentence which initially confused me is this last one:
This meant that I should start calling the same methods and properties in dynamo python node, as the names of the existing dynamo built-in nodes?
For example, there is a dynamo built-in node: âCurtainPanel.Boundariesâ, so I would in dynamo python node call the property with the same name on âRevit.Elementâ object.
Did I understand you correctly?
Yup, correct. That is because the Dynamo Revit âAPIâ only has those 10 functions, there is no such thing as a CurtainPanel class in Revit (although we all know it as curtain panel), this is exclusively a Dynamo Revit object and created to wrap around and extend Revitâs Panel class with useful features (like CurtainPanel.Boundaries) which simply do not exist in the Revit API.
As for API docs, Dynamo does not need a .chm as it is in itâs own right sort of a .chm just with a prettier UI and where you can drag the members in a handy graph.
Correct. The nodes in Dynamo are just method calls on an object, you can call these within python code. These all use the Dynamo Revit âAPIâ if you will, not the proper Revit API. I write an article about this some time ago on how to execute Revit Nodes inside Python. It is no different from how you would with ProtoGeometry Nodes.
For example, the node Element.SetParameterByName can be written equivalently in python like thisâŚ
When using Dynamo Revit methods, you are limited to ONLY what is in the OOTB Library (Dynamo Revit API if you will), which is ever expanding, but still limited when compared to the Revit API. Using the Revit API directly is much more flexible down the line, but you can lose some useful functionality you had when using the Dynamo Revit API. But you can also use them in tandem by converting to and from DS/Revit types. Which type matters here, Dynamo Revit API can operate on DS Types and Revit API can only operate Revit Types (or unwrapped DS Types).
Thank you @Daniel_Woodcock1 ,
For the further explanations and your article. It was quite useful in clearing some of my doubts!
I would still disagree on the documentation of Revit API vs Dynamo API . I am aware that âCurtainPanelâ and âPanelâ classes are not the same. I just gave them as a comparison.
Dynamo Library/Dictionary shows only 10 methods+properties, while in reality there should be 49 of them (the other 39 are probably inherited from âRevit.Elements.Elementâ class).
@c.poupin ,
Thank you very much for the link. I was more looking for the Revit DesignScript Nodes API documentation.