One of the most important, basic and powerful tools for analysing the Revit database is RvtMgdDbg.
A

2009 version

is publicly available, and a

2010 alpha version

is on the ADN web site.
You can also find both of these just by searching for “RvtMgdDbg” on the ADN web site, if you have access to that.
I would have described it in detail much earlier, but the public availability was unclear for a while.
Now that it is clear that it is publicly accessible, I tell you it is a must for every Revit developer to know and use.

The full source code is included.
Therefore, in case of need, you can always recompile it yourself for any version you please.
It can also be used for analysis and learning purposes, incorporated into your own application, and updated in case you discover a problem.

ArxDbg Family

RvtMgdDbg is similar to the ArxDbg and MgdDbg utilities, well-known in the AutoCAD ObjectARX and .NET API developer communities.
RvtMgdDbg is written by the same author and his team.
All of these tools analyse:

  • The database structure, contents and properties.
  • Element properties, methods, data and relationships.
  • In AutoCAD, reactors, hard and soft owners and pointers, the DXF data representation, etc.
  • In Revit, the element parameters and geometry, etc.

The tools provided in this series include:

  • ArxDbg, an ObjectARX tool for analysing the AutoCAD database.
  • MgdDbg, a managed version of ArxDbg.
  • RvtMgdDbg, a Revit API .NET tool to analyse the Revit database.

The class

DE111-3 – A Closer Look at the Revit Database with the Revit API

by Mikako Harada at Autodesk University in 2007 and 2008 uses RvtMgdDbg to explore and explain the internal structure of the Revit database.
The class materials include the version for Revit 2009, a sample model, and results of a detailed analysis of the model elements.
Here is an excerpt from Mikako’s class handout describing its various features.
Many thanks to Mikako for providing the following valuable material!

RvtMgdDbg – ‘Snoop’ Tools

RvtMgdDbg is an external application which defines its own menu and a toolbar, and solely written using Revit API.
It provides comprehensive tests of the Revit API, sample code and utility classes, scaffolding for quick tests.
It is the powerful exploration tool for learning Revit internals.

I have been playing around with RvtMgdDbg for some time.
It is truly a great tool and helps our daily life of supporting Revit API.
In the following sections, I will point out a few tips about using this tool, which you might find useful later on.
This figure shows the main menu of RvtMgdDbg:
RvtMgdDbg main menu
Currently RvtMgdDbg provides the following five commands:

  • Snoop Db – this command allows you to view the Elements list under the current active document or ExternalCommandData.Application.ActiveDocument.Elements. It sorts elements by class name and display them in an alphabetical order. For each element selected, it displays its properties. Figure 6 shows the image from a sample usage of his command. Blue lines indicated the names of class as well as derived base classes. Bold letter in the item indicates the availability of the further ‘drill down’ information. By click it, you can view more information.
  • Snoop Current Selection – this command allows you to view the elements you have selected prior to running this command. The information displayed for each element is same as above.
  • Snoop Application – this command allows you to view the properties of application object.
  • Test Framework – this command consolidates various test commands including ones found in the SDK samples. You can also find more samples here.
  • Events – this command allows you to turn on/off event notifications currently available through Revit API.

Here is an example of snooping around in the Revit database, in this case displaying a list of all database elements with a wall element selected on the left hand side, and its methods and properties in the grid on the right:
RvtMgdDbg main dialogue
All the bold entries in the properties and methods pane can be clicked to open up new windows taking you further and deeper into the data structure and object relationship graph.

Component Families and Types

Earlier I mentioned that the class called Family is like a container class.
A set of family types is grouped under a family.
In Revit UI, you can view it under Families in the project browser.
Take a ‘M_Keynote Tag’ (this is in a metric template), for example, there are three types defined in this family.
In the Snoop Db tool, you can locate this under Family tree node.
If you check the element named ‘M_Keynote Tag’, you can find the member types under Symbols property.
One thing to note is that the class Family has no category defined.
In Revit 2009, you can check ‘FamilyCategory’ property instead:
RvtMgdDbg component family

System Families and Types

The above mentioned Family class is available only for component families (although from the UI, it looks as if they are under Family class).
For system families, there are normally designated, corresponding classes for each type.
For example, the class for wall symbols is WallType.
To find out the family name, you can check the property of a wall type and look up its built-in parameter ‘ALL_MODEL_FAMILY_NAME’:
Wall system families and types
We will look more at Snoop Parameter anon.
Additionally, some but not all system family types are also accessible from the document object:
Accessing types from the document object

Accessing View Specific Instances

One way to access instances is through View.Elements.
This gives only the instances specific to a given view.
Look under the View class, and then click its Elements property:
Accessing view-specific instances
In Revit 2008, you could select a view from project browser, and still be able to snoop it as a current selection.
This functionality was disabled in Revit 2009. I miss it …

Parameters

One last tool I would like to mention is the snoop tool for parameters.
Each element has a Parameters property, which closely corresponds to the property values you see in the Element Properties dialog in UI.
The parameters you can view here may be built-in or shared parameters, including both visible and invisible ones.
To access a specific parameter, you can use the Parameter method by passing in a built-in parameter enum value (note singular form here as opposed to Parameters in plural form).
One difficulty in using built-in parameters is that there are more than 2000 of them defined in the Revit API, while only a small portion of these apply to a specific element.
Unfortunately, there is no documentation, either.
The documentation of built-in parameters is one of most frequent requests.
There is no official document for that to date.
Nevertheless, it has been our experience that occasionally you may find additional information; a family name for a specific wall family type which we mentioned earlier is an example of such a case.
In the SnoopObjects dialog, click on Parameters property fields.
The Snoop Parameters dialog includes a button labelled ‘Built-In Enum Snoop’.
From here, you can view the list of ‘available’ built-in parameters:
Built-in parameters snoop tool
Please note that ‘available’ simply means that its value is not Nothing or null.
If does not guarantee that it has meaningful value.
Built-in parameters are not an officially supported portion of API.
In future we expect it will be replaced by data being properly exposed as a property.

Installation

RvtMgdDbg is an external Revit application, so it needs to be installed like any other such add-in, for instance by adding the relevant lines to Revit.ini.
It makes use of some bitmaps which it expects in a specific location.
You can change the location in the source code as you like and recompile, or simply ignore them, in which case they will not be displayed.
This does not matter, they do not affect the functionality of the tool.

It does occur that some specific properties on some specific objects throw exceptions.
If so, simply start RvtMgdDbg in the Visual Studio debugger, discover where the offending exception is thrown, encapsulate it in an own little try-catch error handler, ignore it and continue, so you can view and work with the rest of the data.
If you make any fixes, we will be happy to hear about them through ADN.
Thank you!

Summary

In Revit, all the elements are bundled together as a single list of elements under Document.Elements and are accessible through the document element iterator.
The element list contains thousands of elements in an unstructured list.
For Revit programmers, a task often becomes to find out a way to identify the object that you are looking for.
In this session, we have taken a closer look at the elements list in Revit drawing database.
Starting with ‘raw’ data, we have analyzed it and learned how much is exposed currently.
We have attempted to group together among those exposed according to the grouping in UI.
We introduced the tool called RvtMgdDbg and showed you how to explore the internals using this tool.
Through these exercises, I hope you now have better view of Revit API than before.

Acknowledgement

Special thanks to Jim Awe and Arjun Ayyar of Advance Development Group of Autodesk.
RvtMgdDbg was developed by Jim Awe and his team and originally intended for internal use only.
They have been continuously improving the tool, and making it available for the developer community.
And many thanks again to Mikako for this overview!


Comments

13 responses to “RvtMgdDbg”

  1. This tool is invaluable, anyone who wants to develop revit API needs this in their toolkit. Great for testing to see if things are possible in the API.

  2. Nicholas Avatar
    Nicholas

    This is a great tool! Thanks for the tip Jeremy. But what does RvtMgdDbg stand for?

  3. Dear Nicholas,
    I’m very glad to hear you like it. It really is invaluable, isn’t it?
    Thank you for your question. I wish myself had thought of mentioning the meaning of the cryptic name from the beginning in the main article.
    Rvt stands for Revit, Mgd for Managed, and Dbg for Debug.
    What Revit is we know, more or less.
    Managed refers to the .NET framework, which provides a lot of background functionality for managing memory, Windows and other system resources, and the interaction of assemblies with each other. The extension of C++ for working with the .NET framework is also called managed C++.
    Debug or debugging is the process of removing errors, also known as bugs, from programs:
    http://en.wikipedia.org/wiki/Debugging
    Mostly using a so-called debugger:
    http://en.wikipedia.org/wiki/Debugger
    Cheers, Jeremy.

  4. Nicholas Avatar
    Nicholas

    Thanks for the information Jeremy, I couldn’t find the meaning anywhere. Your blog is a great source for anything Revit API related!
    Greetings

  5. This is some great information. It is a awesome thing when someone with a wealth of knowledge is willing to help out others.
    I have used the Snoop tool to find a parameter called To Room and From Room from doors and windows. How do I go about getting to this information for my code?
    Thanks in advance.

  6. Dear bfeldman,
    Thank you for your appreciation, I’m very glad you like it. The To Room and From Room parameters are standard Revit element parameters, so everything we have said about them in The Building Coder Parameters category applies, cf.
    http://thebuildingcoder.typepad.com/blog/parameters.
    The values stored by these two specific parameters are element ids identifying the two rooms. A recent example on this blog on accessing an element id valued parameter was presented in
    http://thebuildingcoder.typepad.com/blog/2009/04/revit-api-cases-1.html
    ElementId matId = dupSym.get_Parameter(
    “Material” ).AsElementId();
    Material mat = doc.get_Element( ref matId )
    as Autodesk.Revit.Elements.Material;
    There is not much more I can say on this topic, except recommending you to work through the basics of Revit programming. There is a lot of advice on getting started with the Revit API in this blog and various other online resources available. An up-to-date overview is given in
    http://thebuildingcoder.typepad.com/blog/2009/04/getting-started-with-the-revit-2009-api.html
    Cheers, Jeremy.

  7. Jeremy,
    Just wondering, is the 2010 version allowed to be distributed to non ADN members? Is it uploaded anywhere? I would have thought it would be ok given the 2009 version and its source code are publicly available..
    Just thought I’d check,
    Thanks,
    Rod

  8. Dear Rod,
    Thank you for asking this very pertinent question!
    The Revit 2010 version of RvtMgdDbg is included in our Revit API webcast training material which can be downloaded from the public ADN API training schedule site:
    http://www.adskconsulting.com/adn/cs/api_course_sched.php > Revit API
    The direct link for this file is
    http://download.autodesk.com/media/adn/RevitAPI_2010_Webcast.zip
    For completeness sake, here is an alternative download site for ADN members:
    http://adn.autodesk.com/adn/servlet/item?siteID=4814862&id=12264104&linkID=4901650
    It is thus publicly available, just like the version for Revit 2009 mentioned above.
    Actually, I just created a separate little post for this information to make sure that it gets the attention it deserves:
    http://thebuildingcoder.typepad.com/blog/2009/10/rvtmgddbg-for-revit-2010.html
    Cheers, Jeremy.

  9. Michael Juros Avatar
    Michael Juros

    Can any of these commands work on a file folder of .rfa?Need to generate a master list of all shipped imperial content and user exposed parameters and values? I dont’ want to have to laod and insert instances into a model to export the information. Must be an easier way?

  10. Dear Michael,
    I have no idea what commands you may be referring to, and the answer is an unequivocal yes in any case.
    Whatever Revit API add-in you create, you can cause it to operate on an entire directory hierarchy of documents.
    Cheers, Jeremy.

  11. Moustafa Khalil Avatar
    Moustafa Khalil

    hi Jimmy
    is there a version for revit 2014??? if not what other options may i have to help me get to API world.
    i know only basics in programming C# and VB, and up to date i still find it so hard to get my feet wet in API.
    Would you please advise?

  12. Moustafa Khalil Avatar
    Moustafa Khalil

    sorry for miss typing error : Jeremy

  13. Dear Moustafa,
    Please work through the DevTV and interactive tutorials provided by the Revit developer centre and getting started materials:
    http://thebuildingcoder.typepad.com/blog/about-the-author.html#2
    Cheers, Jeremy.

Leave a Reply to NicholasCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading