Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using DesignScript in Revit addin

Message 1 of 13
3634 Views, 12 Replies

Using DesignScript in Revit addin

Hi all,


I'm trying to make an addin which involves in complex geometry manipulation. I personally find Revit API really cumbersome and tough, and sometimes impossible when it comes to geometry manipulation. So I was looking for other means to do this. One option which came to my mind is the DesignScript library which is also used in Dynamo. In Dynamo one can create an 


and use a method called 


to convert it to



So I was wondering if it would be possible to do the same thing in a Revit addin? Basically get DesignScript to do the heavy lifting and then convert the final objects to the Revit types to be used by Revit API?


Any input is much appreciated.



Message 2 of 13
in reply to: hzamani

Hi Hzamana, 


Discussed with our developer, while running Dynamo, it will do some initialization work for the geometry library, so if you want to run the Dynamo & DesignScript code in Revit Addin without running dynamo itself, unfortunately, I don't think it's working at this point.   


John Wu
Developer Technical Services
Autodesk Developer Network

Message 3 of 13
in reply to: zhong_wu

So hypothetically speaking we must be able to do the geometry library initialisation in the addin directly in the OnStartup or when ExternalCommand is called, the same way that Dynamo does?


Also I can't find any documentation on DesignScript, is the library available for download anywhere?

Message 4 of 13
in reply to: hzamani

I don't think it's an easy work to initialize the geometry in OnStartup() or Execute(), it's Dynamo internal, should have much dependency. But since Dynamo is open source at, you could check the detail code by browsing the C# project.


But another idea is to run Dynamo script in Revit addin, FYI, one guy suggested a tool called Dyno ( )  which is doing that, please check the the post for more information in case it helps.

John Wu
Developer Technical Services
Autodesk Developer Network

Message 5 of 13
in reply to: zhong_wu

Hi John,


Thanks for your reply and input but please allow me not to accept this as a solution. As far as I understand Autodesk doesn't want to encourage people to use DesignScript in their addins as next to nothing information exists on the web about instantiating it and the library itself is also not available as separate download. In other words although Dynamo is opensource, DesignScript is not. Of course using Dynamo in the addin is an option but that is going to cost a lot of memory and performance to instantiate DynamoRevitModel and DynamoCore just to use DesignScript. 


I'm wondering if anyone else has looked into using other geometry libraries such as GeometRi or MathNet.Spatial? 

Message 6 of 13
in reply to: hzamani

I am also looking for the design scrip documentation. For some reason I am unable to convert a Revit space to a Dynamo solid geometry element. I can get the Revit solid but I am unable to convert it to something Dynamo is able to use.  This means that all other things I need to do with the space must be coded in the Revit API as opposed to using existing Dynamo Nodes. Would using "Convert" in the Design Script library solve my problem? If so, what are the inputs I need to give? If there was documentation I might find an answer? 

Message 7 of 13
in reply to: hzamani

I am also quite interested in using DesignScript in a Revit Addin. As hzamani mentioned making geometrical operation with the Revit API is between really complicated and impossible, while the same tasks with DesignScript would be quite simple.


Does any one manage to use DesginScript in an Addin?



Message 8 of 13
in reply to: hzamani

This is a bad idea. Granted using the Revit API for geometry processes is more challenging in comparison to the ProtoGeometry library (Dynamo's geometry library), but you're creating even more problems further downstream. 


Consider the following:

1. ProtoGeometry elements are not compatible with the Revit API, its a completely independent geometry library and requires conversion to Revit API types which will hammer performance.

2. The library is inefficient and lacks a light-weight geometry library and will compound the problems associated with geometry conversion.

3. Converting from ProtoSolids to Revit API solids is a minefield (ShapeBuilder? SAT to DirectShape? ToRevitType()?) which in many cases fails and there are no solutions. (cylindrical solids are a good example - simple elements which fail conversion).

4. Converting Proto arcs to Revit API arcs fails (see here and here) and there are issues with Dynamo 'Curves' (yep, they actually have an abstract class as a top-level class) to HermiteSplines.

5. You will create a dependency with Dynamo and be forced to either launch Dynamo before running your app to make API calls to the ProtoGeometry library or distribute Dynamo with your add-in which then causes conflicts with the Dynamo installation on the users machine.


Practically everything in the ProtoGeometry library can be achieved using the Revit API. I would spend the extra time using it (the Revit API) as the additional time and effort will be significantly less than the amount of time you'll waste trying to convert the geometry into something usable in the Revit API.

Message 9 of 13
in reply to: thomas

@thomas I doubt that everything in Dynamo Geometry can be achieved by using Revit API. Could you find the intersections of two Faces in Revit API so that it returns a Face, Curve, or NotIntersected? I'm afraid not.


Message 10 of 13
in reply to: htlcnn

There is always the possibility, for example, if there is a method in the ASM (which both Revit and Dynamo use, hence why in theory, anything Dynamo can do, can also be done via the Revit API) which isn't publicly exposed. 


You are wrong about claiming there is no way to perform a face v face intersection via the Revit API and return a curve. You need to use the Face class Intersect method which sets the curve via its out parameter as shown below.


To establish if two faces intersect, simply evaluate the FaceIntersectionFaceResult enum which this method returns. A face > face intersection doesn't make much sense, I think you mean trim a face with another face, like punching a hole through a source face and cutting face? You cant do that in Dynamo or Revit, but there are still workarounds. 


Ultimately this all boils down to the right tool for the right job: Revit and Dynamo have their uses, but there are far more powerful computational and parametric design tools out there with highly evolved geometry engines which may suit your workflow better. Grasshopper/Rhino or Microstation/GC are two alternatives which each have their own pro's and con's but underpinned by highly sophisticated geometry engines which easily surpass Revit/Dynamo.


I suggest you use and search for what you need so you can ascertain whether a function in Dynamo is in the Revit API (99% of cases the answer is yes), or if you just have a general goal, its always a good start point. 


Message 11 of 13
in reply to: thomas

I doubt that you really used that method to get Face vs Face intersection. I'm also very familiar with Revit API SDK and (and recently). There are even some blog posts on thebuildingcoder that prove the Face.Intersect(Face, out Curve) method doesn't really do what its name might imply. If you haven't tried, I'll save your time by confirming that the method always returns a result, even if two bounded faces are not intersected. For reference, here's latest blog on that topic:

I read and write code every single day. I hope you won't feel sleepy reading those lines of code. You could relax your eyes by seeing and understanding images in that blog post.


About Dynamo's geometry capability, I also doubt that you really used Dynamo to do any geometry intersection. I've used it many times and getting a hole on a Face is easy as connecting Nodes using Wires. Don't believe? Try it!



Message 12 of 13
in reply to: hzamani


I just needed run CivilConnection from a revit addin so that i want to have more control to bring data from Civil3d to Revit. This is how i found that topic.

I have also couldnt run ProtoGeometry.dll but after some digging inside the Dynamo Sandbox i managed to run it.


The code extracted is below:


DynamoModel model;
model = StartupUtils.MakeModel(false);


This is somehow managing the related ASM libraries to load and some other management.


I just wanted to ask also the subject is about 4-5 years back so if anybody found a more elegant solutions.


Message 13 of 13
in reply to: yekose

There is a much better/more elegant way nowadays: Rhino Inside. We've successfully implemented it into a Revit addin with amazing results and are currently doing the same for an enterprise-grade AutoCAD addin. RhinoCommon and its geometry library are leaps and bounds ahead of ProtoGeometry. If you're looking for alternatives as the Revit API isn't cutting it, Rhino.Inside (inside-professionally-developed-GUI-applications) is a no-brainer IMO. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th

Rail Community