I am regularly forced to return to this topic, to provide a useful starting point for beginners.
The amount of available material is getting huge, and some help is required deciding where to start exploring the Revit API.
The most important thing to be aware of is the Revit Developer Center.
Start there by looking at the three DevTV video introductions and then work through the My First Revit Plug-in tutorial.
In these tutorials, you are shown how to locate, install and use the most basic development tools and information, including:
- The Revit SDK or Software Developer Kit, including
- The Revit API help file RevitAPI.chm
- RevitLookup, an interactive database element and relationship explorer and massive source code example in itself
- The SDK sample collection, including
- The samples themselves, each one equipped with its own read-me file
- SamplesReadMe.htm: documentation and overview
- SDKSamples2013.sln: a Visual Studio solution to compile all samples in one go
- RvtSamples: an external application to load, test and debug all samples
- The Revit API Developer Guide
More detailed overviews of the available Getting Started material are provided for both Revit 2012 (still valid for 2013) and 2013. You should also take a look at the list of things to do to prepare for a hands-on Revit API training.
I suggest performing these steps:
- Watch the videos
- Work through the tutorial
- Install and explore the SDK
- Compile, install and test RevitLookup
- Compile the SDK samples
- Install and test RvtSamples
- Use RevitLookup to explore a Revit database or two
- Browse the documentation and developers guide to your heart's content
Once you have completed these steps, you will be amply set up and ready to go, raring to get started properly on your own project.
Here is a list of typical questions you might run into:
- How can I determine the relationship and dependency between elements?
- How can I integrate Revit data with an external database?
- How can I extract DWFX data from Revit?
- How can I modify the DWFX results?
- How can I extract a thumbnail image for a specific element?
- How can I get a total count of properties, attributes and custom attributes for a given element?
- How can I compare the properties of two elements?
- When extracting data from Revit, what is the best approach to organize and retrieve that data?
- Is there a standard for all families and element types (symbols) that remains the same from model to model?
- Is there an easy way to list of all families and element types from a model?
- What methods are there to "walk" all objects?
How can I determine the relationship and dependency between elements?
Revit maintains a huge number of different relationships between database elements. How to determine these depends on the elements in question.
An extremely important tool to explore the relationships between elements in the Revit database is RevitLookup, included with the Revit SDK. Use of RevitLookup to explore the Revit database and relationships between elements is discussed and demonstrated in a large number of subsequent posts on The Building Coder blog.
An important technique to discover relationships that are not officially provided through the Revit API is demonstrated by the object relationship analyser (VB). Use of this technique is also discussed and demonstrated in many places.
Most relationships are accessible through much simpler official means, though.
As said, it depends on what elements you are talking about.
How can I integrate Revit data with an external database?
Please look at the following discussions:
How can I extract DWFX data from Revit?
Use the Document.Export method taking (String, String, ViewSet, DWFXExportOptions) arguments.
How can I modify the DWFX results?
You can export the DWFX. For any further modifications, you would have to take recourse to the DWF Toolkit.
How can I extract a thumbnail image for a specific element?
Look at the discussions on
How can I get a total count of properties, attributes and custom attributes for a given element?
You can easily achieve this, but there is no specific API call provided for this task. You have to implement it yourself, and the number will vary depending on your requirements, criteria, and implementation.
How can I compare the properties of two elements?
[Q] For instance, if two different objects have a property of the same name, can their values be compared or summarized together? E.g., a property of "Material" for a length of pipe might be copper; will a property of the same name on a copper elbow joint have the same "Material" value?
[A] I am pretty sure that a clever user can create a project in which this will not be the case.
When extracting data from Revit, what is the best approach to organize and retrieve that data?
That depends completely on your own needs. You will need to perform a careful analysis. Look at the database integration links listed above.
Is there a standard for all family element types (symbols) that remains the same from model to model?
No, unfortunately, the contrary is true. Families and types are completely user defined, and creating their definitions is just as much an art as a science.
Is there an easy way to list of all families and element types from a model?
Yes. To list all types, just filter for all ElementType objects:
FilteredElementCollector a = new FilteredElementCollector( doc ) .WhereElementIsElementType(); foreach( Element e in a ) { Debug.Print( "{0} {1} is an ElementType.", e.Name, e.Id.IntegerValue ); }
To retrieve the families that they belong to, you can use the FamilySymbol.Family property.
And: I can promise you some surprises if you start exploring this :-)
What methods are there to "walk" all objects?
The filtered element collector is the only way to access in and retrieve elements from the Revit database, unless you have a unique id or an element id and can access the individual object directly.
Please look at the RevitLookup application, which is provided in source code as part of the Revit SDK.
First of all, it is an invaluable tool both for developers and even end users to interactively explore the database and relationships such as the ones you are asking about.
Secondly, it iterates the entire database and walks all the objects, so you can use that code directly.
Conclusion
I hope you find this useful.
In general, almost every single question that you run into in your initial steps of implementing a Revit add-in has already been asked and answered somewhere. Make good use of the help file, global search of the sample code, developer guide and then turn to an Internet query.
Believe me, it is easy and it is fun... both the development part and the research... it is all creative :-)
Good luck!
Project Tracking for Kids
Oh, and one last thing... where tracking is child's play... a few days late for April first :-)
Can you please give me some useful hints about how to display a form with controls and interact with revit
thanks sir
Posted by: yasser | April 05, 2013 at 16:59
Dear Yasser,
Sure. Look at the Getting Started material, the SDK samples, and previous blog posts.
Cheers, Jeremy.
Posted by: Jeremy Tammik | April 08, 2013 at 08:42
Thanks Jeremy,
I am using Micosoft Visual Express 2012 for Windows Desktop and noted in the link http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=16849339
Step 3 Save the project:
On the File menu, click Save All. In the display window type C:\test in the Location box, and then click Save.
Ok, so I did, but the part about "display window type C:\test in the Location box" didn't provide any pop up to define the save path as C:\test so to leave me high and dry perhaps.
Currently the project is saved to this path C:\Users\david metcalf\Documents\Visual Studio 2012\Projects\Lab1PlaceGroup\Lab1PlaceGroup\ which I assume is the default for VB 2012.
So I decided to leave that thinking it is a VB 2013 thing. Ok, so proceeded with the next several steps as outlined in the rest of the tutorial. (I chose to ignore the MISL Processor warnings for now) After which the I created the AddIn Manifest. I intended to change the 5th line for the location of the dll file from C:\test\Lab1PlaceGroup\Lab1PlaceGroup\bin\Release\Lab1PlaceGroup.dll to C:\Users\david metcalf\Documents\Visual Studio 2012\Projects\Lab1PlaceGroup\Lab1PlaceGroup\bin\Release\Lab1PlaceGroup.dll and couldn't find the expected path ..\bin\Release\ or the dll file.
I think at step three I went 90 degrees somehow.
Any suggestions to getting on track here and find that dll file or did some how it not be created? I did a search and no Lab1PlaceGroup.dll file was found
Thanks, David
Posted by: David Metcalf | June 19, 2013 at 19:27
Dear Jeremy,
I want to draw a RevisionCloud in Revit using C# programmatocally. I tried to generate a macros, it's not working. I have a collection of Points. will you please help me in this. I am trying some demo application.
Thanks and Regards,
Vidyasagar Apgunde
Posted by: Vidyasagar | June 21, 2013 at 06:38
Dear Vidyasagar,
I do not believe that the Revit API currently provides directly support for the insertion of revision clouds.
You could try launching the built-in Revit revision cloud command programmatically instead.
Look for UIApplication.PostCommand in
http://thebuildingcoder.typepad.com/blog/2013/04/whats-new-in-the-revit-2014-api.html
Cheers, Jeremy.
Posted by: Jeremy Tammik | June 21, 2013 at 07:07
Dear David,
Nope, sorry, no idea.
Did you find a solution, meanwhile?
Cheers, Jeremy.
Posted by: Jeremy Tammik | June 27, 2013 at 08:23
Hi Jeremy,
I got pulled onto a project so haven't revisited it. I'll need to find some one more cognizant of the VB 2012 software. Think the tutorial was written with VB 2005 as a programming medium. Oddly enough, after a search, there is no relevant dll file to be found on my hard drive.
Thank,
David
Posted by: David Metcalf | June 27, 2013 at 11:27
Hello Jeremy,
I have got a two questions.
Is there any way to extract project's model geometry and material properties in one file? (in text format, such as .xml)
The case is that..We are working on the idea of itegration of fire simulation engine with Revit. So what is critical is to have geometry of building model as well as the material properties (such as resistance or thermal mass) as an input data for fire simulations.
Alternative solution could be to somehow export Revit data (geometry, properties) into Visit software (visualization software where our simulations could typically run)Is this implementable?
The worst part is that I am pure beginner in Revit API.And do not know how to better approach this deal.
Hope for your help!
Thanks
Alexey
Posted by: Alexey Igorevich | October 02, 2013 at 21:08
Dear Alexey,
Sure that can be achieved.
Look at the custom exporter:
Graphics Pipeline Custom Exporter
Texture Bitmap and UV Coordinates
ADN Mesh Data Custom Exporter to JSON
Determining Absolutely All Visible and Hidden Elements
Cheers, Jeremy.
Posted by: Jeremy Tammik | October 08, 2013 at 12:10
Jeremy,
Thanks for your response.
I read through all of the links you've provided and I also tried custom exporter xml. It looks great but I still can't find a thermal properties of my model's elements in the exported xml file.
I made a little research by Revit LookUp and figured out that thermal mass/resistance are linked to my geometry through "object type" and its parameters. So I guess, custom exporter exports just parameters that appear visually (texutre, glossiness etc.) but not linked parameters such as thermal properties. Is it right, Jeremy?
If yes, is there alternative ways to obtain these thermal parameters with geometry? Or I need to export geometry and thermal properties separately and then (somehow) link them together?
Thank you
Alexey
Posted by: Alexey Igorevich | October 09, 2013 at 21:21
Dear Alexey,
What you say makes a lot of sense.
When you implement your custom exporter, you can easily query the element providing the geometry for its type, and query that in turn for the required properties, and combine all the data of interest in you output in any form you like.
Cheers, Jeremy.
Posted by: Jeremy Tammik | October 14, 2013 at 08:15
Thank you for your help, Jeremy
Best,
Alexey
Posted by: Alexey Igorevich | November 01, 2013 at 13:53
Dear Jeremy,
Thank you..
Sorry for late reply.....
Posted by: vidya | December 10, 2013 at 04:19
Hi Jeremy,
Do you know if this API can be used by other application (not as a Revit plugin) to read and convert Revit files. Do you think the license permit this?
Thanks
Eric
Posted by: Arik | December 11, 2013 at 07:44
newbie to this, so thanks for info: I'm in the middle of looking into this, and ran into some problems with the 'My first Plugin' tutorial.
Using the MS VS s/w (express 2013? i think, under crap win 8.1), and typed in the first plug in code, but refuses to build...
i thought i might have to 'downgrade' to the 2010 version, since that appears to be what the tuts are based on, but it appears others have done this exercise with 2013 versions...
the other confusing part is, .NET is apparently installed in several flavors, but none of them appear to work with the build...
is there something stupidly obvious i am overlooking ? not conversant enough with this to know where i am going wrong...
Posted by: Charley Yancey | December 30, 2013 at 10:45
Hi Jeremy,
İ have installed revit 2015 and SDK 2015 but when i create module for creating macros,i get an error 'loading the Macro failed'.So I cant start to create macro.İ couldn't find the problem.İ hope you can help me...
Posted by: Mehmet Özer | June 29, 2014 at 13:24
Dear Mehmet,
No, I do not know what the problem might be.
I googled for "revit 2015 loading the macro failed" for you, but nobody else seems to be observing such an issue either.
Good luck resolving it.
Cheers, Jeremy.
Posted by: Jeremy Tammik | June 30, 2014 at 11:22
Dear Jermy,
I very appreciate for your web page and reply message, that is very useful for us. Let me know one thing , I wanna automatically layout the sprinkler point in Revit MEP base on the link autocad which already have layer name for sprinkler.I mean, API can read the autocad layer name, after that sprinkler point put in that layer name object. I wanna write a API for these issue, Is it possible?
Best Regards,
Naing Oo
Posted by: Than Naing Oo | June 17, 2015 at 23:09
Dear Than Naing Oo,
Thank you for your appreciation.
It sounds perfectly possible to me.
If you need to interact with AutoCAD and you have both AutoCAD and Revit installed on the machine, you can make use of the AutoCAD.NET API from within your Revit add-in.
Cheers, Jeremy.
Posted by: Jeremy Tammik | June 18, 2015 at 01:33