Hello, All,
After a good experience with Dynamo and Revit API, I have many questions to discuss with the experts here in the forum. I hope to get more ideas and get some useful techniques.
The first question is: It seems that there are some methods and properties in Dynamo which do not exist in Revit API, right?
In case of “yes” in Q1. I think dealing with geometries through Dynamo is much better than through Revit API, right? This is due to the more effective methods in Dynamo, right? I wonder if everybody feels the same! I still have doubts and I feel I miss something in Revit API.
Although most of the methods and properties in Dynamo exist in Revit API, I think some tasks cannot be done without merging Revit API and Dynamo together, right? I mean, not everything can be done with API only, is that true?
If I have to merge between Dynamo and Revit API, what is the best practice for this? I tend to deal with everything in the python script including importing Dynamo methods, Wraping and Unwraping elements…etc but I found that some people don’t prefer this technique and I don’t know why!
Thanks in advance. I am looking forward to making use of your ideas, All.
The first thing to understand is that Dynamo itself is not tied to Revit. Dynamo is its own thing that has access to multiple design softwares (Revit, Civil3D, Formit) and their APIs. Both Dynamo and whatever software/API you may be using can, and do, operate on their own as well as together. If you ever open up Dynamo sandbox you will see that it’s missing all the Revit nodes because Sandbox does not have access to Revit and therefore also doesn’t have access to the API. What you’re likely used to is Dynamo for Revit, which is the Dynamo application that comes installed with Revit and has access to the Revit nodes and Revit API.
So yes, Dynamo does things the Revit API cannot because it also exists outside the realm of Revit and has to support functionality that may or may not exist outside the realm of Revit use. This is also why there is overlap between Dynamo and Revit API capabilities.
I would agree that Dynamo is easier for geometry interactions. I wouldn’t say that it’s necessarily due to “more effective methods”, the Revit API is just as effective, but that Dynamo geometry is just simple representative geometry and doesn’t require the specifics of the Revit API. It tends to be more streamlined and generic.
As I explained earlier, Dynamo and the Revit API serve two separate purposes so it’s unfair to compare their functionalities directly and say one or the other is “missing” something. Dynamo for Revit has nodes that are completely unrelated to Revit as well as nodes that duplicate API functionality. You could do everything exclusively through the API if your workflow was exclusively Revit focused. Obviously if you’re dealing with something outside of Revit then you would have to use something that offers functionality outside of Revit.
Best practice for combining Dynamo and Revit API functionality is whatever works best for you. There are some performance benefits to using python over Dynamo, but that’s not exclusive to Revit or its API. Some people might say you shouldn’t combine Dynamo functionality and the Revit API within the same python node. Partially due to wrapping/unwrapping like you said, but it can also just be messy and cause confusion or conflicts if you’re not careful.
Hope that’s helpful. Others might have differing opinions, but that’s my two cents.
Regarding this sentence, I belive it is true but it somehow depends on the programmer skills and knowledge. For example, yesterday I wanted to project a point onto a specific plane in a nonorthogonal direction. There is a direct node in Dynamo to do so. In Revit API, I think I should do some math interpolations to get the projected point. I don’t know how for now!
Thanks, Nick. Your reply is very useful and interesting to me.
Exactly. Dynamo tends to have a lower barrier to entry for a lot of this stuff. This example in particular goes back to the point about geometry manipulation. Revit is made to do very specific things. Sometimes that means additional logic is necessary in order to make something work that may not have a specific Revit method already. Whereas Dynamo is made for the generic and tends to have more broad access to certain functions. This is also where that combination of Dynamo and Revit API comes in handy. Dynamo can be used for the things Dynamo does best and the API can be left for the things that Revit does best.
For me, this is true for topics other than geometries. Can u for example project a point on a plane in a specific vector (not orthogonally) with only the API? If yes, I am very interested on the way.
The Revit api is good at what it is built for - Revit tasks. Most design work isn’t a Revit task though, and Dynamo is vastly more effective then Revit in those tasks as it has a significantly more robust geometry kernel.
The capability to pull a point onto a plane isn’t a great example, as that has an equivalent command in both, but the capability to find out if a point is inside a solid geometry is a good example, as Revit doesn’t have such a tool in it’s API. In Dynamo we’d just use ‘Geometry.DoesIntersect’, while in Revit you have to:
Translate the XYZ by the document’s minimum distance by a positive and negative XYZ
Create a bound line between the translated XYZ values
Intersect the line with the solid
Confirm the distance of the line is at least as long as the minimum distance of the document
Other examples of things which are faster in Dynamo’s API:
Building a cuboid, sphere, or other primitive
Converting a solid to a mesh and vice versa
Working in non-Cartesian coordinates systems
Dealing with really big or really small geometry
Creating and editing polycurves
Much of the ‘Revit API’ is faster perspective is also due to how the tasks are called. Direct API calls in Dynamo and Revit (not placing nodes but writing the code to do work) will usually have the similar times for the same task, with the notable exception of items where the Dynamo task is a Dynamo for Revit call rather than a Dynamo Core call as these have to not only do the work but also convert from Revit data to Dynamo data. This translation can be time consuming so when possible it’s best to ‘reduce the trips to the well’ and limit the number of times you have to go back and forth.
It’s also worth noting that much of the inefficiency associated to node based build outs is due to the memory consumption inherent to how nodes are built up. Each and every list which is generated along the way is kept in memory while the graph is open, while the Revit API allows disposing of data as you go (or as is common in Python overwriting the data in memory directly). Having more memory available can hell reduce this. However that can be difficult to provide in the context of Dynamo for Revit as I believe the host application (Revit) gets memory allocation first, and Revit needs 20x the the file size just to open up a document, and as a result Dynamo for Revit will usually suffer.
It’s great to read your reply, @jacob.small
I had the same thoughts although my experience is nothing if compared to yours.
A big thanks for sharing your deep knowledge.
I knew about this method but I want to project a point on a plane in a specfici direction not orthogonally. This needs some math manipulation. I will study the link given by @newshunhk and try it.
Thank you, both.
I have read the website and I want to say that it reminds me of university memories
I get the technique and will apply it to my script once I open my laptop.
Thanks, bro, and by the way, Is that your blog?