Thursday, November 18, 2010

[Revit API]–A couple more Revit API Blogs to follow

Just a quick note to let you know about a couple of blogs I’ve recently discovered that have a large amount of Revit API content.
First off, check out ‘Daren@Work’ which is the blog of Daren Thomas, creator of RevitPythonShell.

Secondly, Don Rudder has a blog ‘Revit .NET Development’.  Don wrote the Revit API chapter in Mastering Autodesk Revit Architecture 2011 which I recently purchased a copy of. He is also presenting at this years AU.

I’ve added these two sites to the index for, so their content will be easily searchable along with the other Revit API blogs and forums that I’ve got listed there.

If anyone else is writing a Revit API blog and would like to be included in the links on the right hand side of this page, and in the Revit API Search engine, please let me know.

Friday, November 12, 2010

[General IT] How to open Powerpoint on multiple monitors

I’m a self professed multiple monitor addict. On my laptop I have a USB video card along with the two inbuilt outputs to give me 3 monitors. While at home on my desktop machine I run 5. Some may debate the benefits of having multiple monitors (I’d say above 3 is getting a little bit shaky on the cost-benefit analysis), but I’m constantly finding instances when it comes in handy.

Windows 7 is great for multiple monitors, the shortcut keys (Windows + arrow keys) to move the active window to other screens are great, it remembers my screen setup when I move my laptop from work to home, and Ultramon allows me to have a taskbar on each monitor (which is essential for me, given I have a tendency to have a million things open at once, here’s hoping this comes inbuilt to Windows 8). Most of Microsoft Office is great for it too, you can easily open multiple instances of Word and move them across monitors to easily refer to them. However there is one program that inexplicably does not let you open more than once instance of it, Powerpoint.

While obviously for giving presentations this isn’t an issue, whilst preparing for my AU2010 class I wanted to refer to old presentations, the AU template guidelines and more, which were all in Powerpoint form, so naturally I wanted to make use of my screen real estate. I can imagine many other scenarios when I’ve had more than 1 Powerpoint file open at once, and dragging it out across monitors just doesn’t cut it for me, so I decided to do some searching.

After some looking around, I found a solution:

You can open Powerpoint once the normal way, and then you can trick Powerpoint into opening another instance of itself. To do this, you need to run it as another user. First, make sure you have another user created on your system, you can do this in Control Panel\User Accounts\User Accounts. Then, go to the actual folder where the Powerpoint exe is - "C:\Program Files (x86)\Microsoft Office\Office12\POWERPNT.EXE" is what it was on my 64bit machine with Office 2007 installed. This will be difference for 32bit machines and different versions of Office.

Then, on Windows 7 you can hold down the shift key, and right click on the exe, and click ‘run as different user’ – enter in the new account that you’ve made, and it will start a new instance. Success!


A couple of gotchas to note, first, the shift key to get extra menu options only shows run as different user in Windows 7. There are ways of doing this in XP and Vista though (a command line utility, and I think XP has it on the context menu by default, from memory). Secondly, the my documents menu when you go to save or open documents on the new instance will be that of the new user account you created. You can of course still access your real My Documents folder manually by going through C:\Users\Username\My Documents (on Windows 7).

Hope this helps!

Friday, September 17, 2010

[General IT]–One click image uploads with Clupper

I’ve been using a really handy tool lately, called Clupper. If you are someone who is always sending screenshots to people online, perhaps adding them to forums/social networking, or sending support requests, this could save you some time.

Once you’ve downloaded it and set it up, it will sit in your tray. To use it, all you do is take a screenshot, and then click it. It will then upload the image and copy the URL to your clipboard.

Combine this with the Windows 7 Snipping Tool and you have a really easy way to send clippings to others. For instance, the above image, I opened the snipping tool, selected that area, then clicked on the pink arrow.


It then uploads it to my pre-configured FTP site (it can also use image hosting sites) and then gives me the URL. This is also handy when you use the ALT+PrintScreen windows shortcut to take a screenshot of the active window.

Have a look at it

Wednesday, September 1, 2010

[Revit API] Autodesk University 2010–Introduction to the Revit API

The Autodesk University class listings for both physical and virtual classes are now available on the AU website. Head over there and take a look, there are lots of great looking classes. It is also available in a handy spread sheet format.

This year they have tried to mix things up by changing the class selection a little bit, instead of having the same speakers present the same classes (even though they have been doing a great job of it) they have decided to try and get some fresh new content. Whilst new content is great, there are some classic ‘must have’ classes, and for those they have tried wherever they can to give a new speaker a chance to present on those to get a different perspective.

One such ‘must have’ class is the ‘Introduction to the Revit API’ class, which as a part of the changeup, I have the privilege of presenting. I have a high standard to live up to, as in previous years Danny Polkinhorn has done a stellar job of presenting this class, and helping many people to take their first steps in Revit API development (including me!).

The class description is this:

From Hello World and beyond, this class will take you through the steps of creating a Revit add-in from scratch and registering it to run inside Revit using the Revit application programming interface. You will learn how to get input from the user, access their currently selected elements, and read and write to and from the project database. Learn how the RevitLookup tool can help you to get familiar with the Revit file structure and debug your application, and learn how filters can help you speed up your database searches. With a little Microsoft® .NET programming knowledge, you can create great add-ins for Revit. This class shows you the basics that you can then build on. Some .NET programming (C# or Visual Basic®) experience is recommended.

It is a 60 minute lecture, on the first day of AU in November.

I would love to hear from anyone who is attending this class as to anything they would like to see included that isn’t listed in the description above, its not a huge timeslot so I won’t be going into great detail (there is a great range of Revit API classes this year that will cover more in depth topics), but I would like to hear from people who have maybe just started learning the API as to what certain things you found difficult or what gotchas you had so I can make sure I touch on those.

From my talks with people locally who have been trying to learn the API the first challenge is that of learning C# (or VB.NET), as a result I have been contemplating doing a sort of ‘C# for Revit Users’ webcast/blog post series in the lead up to AU. Stay tuned for information on that.

Tuesday, August 10, 2010

[General-Dev] How to download FXCop 10.0 (Version after 1.36)

FXCop is a code analysis tool from Microsoft. It helps check your code against a number of pre-defined rules as well as giving you the ability to add your own. It has been around for a while and is a good way of making sure you write code in a clean style.

It might sound weird writing a blog post on how to download a simple piece of software, but it is a bit of a muck around to get this so here is how to do it.

First of all, Version 1.36 has been superseded by version 10. I guess this is to line up with Visual Studio 2010.

Secondly, you can no longer download the installer from Microsoft's website. In fact the download page for it, simply downloads a text file which tells you to download something else.

Here is what you need to do.

1. Download Microsoft Windows SDK for Windows 7 and .NET Framework 4

2. Run the installer, it is a web installer, when prompted all you need to install is ‘Tools’ under ‘.NET Development’ (note, if you install everything its a large download! If you want to install everything it might be best to get the ISO from Microsoft's website).

3. Once its installed, go to "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\FXCop\FxCopSetup.exe" and run the setup.

4. You will then have FxCop installed, on 64bit machines it is located in “C:\Program Files (x86)\Microsoft Fxcop 10.0”

Note that I ran into problems when I just copied the fxcopsetup.exe onto other machines, had a dll error, installing the ‘tools’ from the web installer fixed that, so I guess this is why they haven’t just uploaded fxcopsetup.exe

Hope this helps you to not become as frustrated as this guy!

Sunday, July 4, 2010

[Revit API] Document.PrintManager returns a new instance every time

A gotcha that you may run into if you use the Print API in Revit is that the PrintManager property of a Document always returns a NEW PrintManager.
So if you make a change (say to the print range) of Document.PrintManager directly, it will be pointless.
Document.PrintManager.PrintRange = PrintRange.Select;
//then submit print

both will act on a NEW PrintManager each time, which isn’t what you want. What you need to do is maintain a reference to PrintManager yourself, only calling Document.PrintManager once.
PrintManager manager = Document.PrintManager;
manager.PrintRange = PrintRange.Select;

If you have a look using Red Gate’s .NET Reflector to disassemble that method in the RevitAPI.dll, you can see why:
public unsafe PrintManager get_PrintManager()
    PrintManager manager;
    REVIT_MAINTAIN_STATE revit_maintain_state;
        manager = new PrintManager(this);
        ___CxxCallUnwindDtor(REVIT_MAINTAIN_STATE.{dtor}, (void*) &revit_maintain_state);
    return manager;

As convenient as only passing around the Document object is, it’s not going to work! Changes made to one instance are not likely to apply to any others.

Wednesday, June 2, 2010

[Revit API] Dynamic Model Update in the 2011 API

After completing the larger than normal task of converting my suite of Revit add-ins over to the new 2011 API, I’ve recently had the chance to sit down and start having a good play with the new features.

One feature which I have been particularly excited about is the new Element Level Events, also known as Dynamic Model Update. Basically, this lets you attach an event to a particular type of element, and when that element is changed, your code gets called, and can do various things. This is a feature which the team has clearly put a lot of thought into, and it opens Revit up to a whole new level of automation. Page 283 of the developers guide has a good introduction to this, and the example they use is changing all new walls to a certain type.

My first idea for using this tool is to solve a problem that some of the drafters at the company I work for have been complaining about, which is detail lines in Revit. When they want to insert a detail line they hit the keyboard shortcut, and select from a long list of different line styles, then draw the line. If they are doing lots of lines, they will scroll through that list many times – which is annoying. My idea was that they could tell my add-in what line style they want to insert, and then just draw detail lines without scrolling through the list each time.

The process would be this:

  • User runs the tool which registers an updater, and sets the line style.
  • When a new line is entered, that updater will be triggered
  • The updater will then convert the newly inserted line to the line style selected.

It was actually quite easy to get this working, which is a testament to how well this API is written.

First you need to create a class that implements IUpdater. Mine was called DetailLineUpdater. You then need to implement each of the members of that interface. These include:

  • Execute(UpdaterData data) – this is the actual method thats called when the updater is triggered, here is where I would change my line style.
  • GetAdditionalInformation() – just returns a description
  • GetChangePriority() – tells Revit the nature of what you will be doing in the Execute method. Revit uses this to determine in which order it should run each of the updaters.
  • GetUpdaterId() – returns an ID for the updater, which includes the AddInId and a GUID
  • GetUpdaterName() – a name for your updater. Make this something meaningful as it may get displayed to the user.

As you can see, these have some similarities to the kinds of things you need to tell Revit about your external commands.

Once you have your updater class, you need to do two things:

  1. Register it, using the UpdaterRegistry.RegisterUpdater(updater) method.
  2. Tell Revit when to trigger it.

For the second point, you need to use the UpdaterRegistry.AddTrigger method, which accepts three parameters.

  1. The id of the Updater
  2. A filter, which tells Revit which elements to attach to.
  3. A change type. This defines what actions on the filtered elements will trigger your updater. This could be insertion, deletion, parameter changes or geometry changes.

For my tool, I got the change type by using Element.GetChangeTypeElementAddition().

So now I have some code that will be run, whenever a certain type of element (in my case, elements with the category OST_Lines) is added. Here is a snapshot of the registration code:

DetailLineUpdater updater = new DetailLineUpdater(commandData.Application.ActiveAddInId);
                ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_Lines);
                UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), filter,Element.GetChangeTypeElementAddition());

Most of the IUpdater methods are trivial, but here is my Execute method:

        public void Execute(UpdaterData data)
            foreach (ElementId addedElement in data.GetAddedElementIds())
                DetailLine line = data.GetDocument().get_Element(addedElement) as DetailLine;

                foreach (Element style in line.LineStyles)
                    if (style.Name.Equals("A_Certain_line_style"))
                        line.LineStyle = style;


As you can see, its all fairly simple, and works well! However, there is a catch.

Once you use an updater on a model, it permanently stains it.

What do I mean by stain? It leaves a mark. Its not a huge deal, and doesn’t affect the model, but from a software developers point of view, its not ideal. If you run a tool, such as my line styling tool, and then someone else opens your model, or even links it into their project, they get a warning saying “the file … was modified by the third-party updater …… which is not currently installed”.

If you continue to edit the file, data maintained by …. will not be updated properly. This may create problems when … is later opened when …. is present.


The user can easily just click the second option ‘Do not warn about this updater again and continue working with the file’. But I believe every user will have to do this (have not confirmed this though, would love to hear if this is not the case), and I’d imagine, if you send your model to other firms to link in, they will all get it. This is not a good user experience, and would scare or confuse some users.

The intentions behind the warning are good, the Revit team obviously doesn’t want problems seen in AutoCAD where third party add-ins are so intertwined with projects that they cause a troubleshooting nightmare. But for simple time saving add-ins like my line styling tool, this is inconvenient. I’d love for there to be an option where developers can say that honestly if the updater is removed it will not cause any problems, and then that error will not show, hopefully next release!

All in all, this addition is great, and makes a range of great new add-ins to be made, but when your tool is not installed, users get this dialog, which could be confusing. If this doesn’t affect you, then I encourage you to get in there and have a play around, its easier than you’d think it would be, and I’m sure you’ll come up with some great ideas of how you could utilize it.

Saturday, May 22, 2010

[Revit] RTC 2010 + AU 2010

Over the last few days I’ve been attending the Revit Technology Conference in Sydney, Australia. Just finished doing my presentation on the Revit API which went well.

I encourage you to check out the conference, which while it is in Sydney this year, there is going to be a USA version next year as well. It is well run, a min-AU of sorts.

Speaking of AU, as you’ve probably heard voting is open for classes for this year. I have a couple of submissions in, first is an Introduction to the Revit API class, and the second one I am a co-presenter on.

A colleague of mine, Paul Cashman has submitted a class to discuss setting up a family library in your office, and some great tips, procedures and what not on how to encourage people to participate, set out the library well, keep quality and to document it. I am listed as a co-presenter as I will be talking for a little while on our Family Management system, which if you saw my AU or RTC class involves a web based interface which links in with Revit to provide up to date information and documentation on families, versioning and other information. It has also been recently updated to allow an audit on your model, to find out of date families & load the latest in.

It would be great if you have an AU site account to vote for that class, as it would be great to share the details of that with you all! I’m not sure if these direct links work, but here is a link to vote on that particular class! If it doesn’t, the class is called ‘Establishing and Maintaining a Revit Family Library’


Thursday, April 15, 2010

[Revit API] – Visual Studio 2010 and Revit API debugging issues

Visual Studio 2010 is now officially out, and it is great! Some excellent new features, the new look is great, and you can drag code windows to different monitors!

I have installed it and have started working on my Revit API tools with it. Straight away I came across a stumbling block. My API code threw an error, but it was not caught in the debugger, and none of my breakpoints were not hit. After some investigation, it seemed that Visual Studio was not attaching to the Revit.exe process as it should. I tried manually attaching to the Revit.exe process and that seemed to work, but this is a bit of a pain, why doesn’t it automatically attach?

I Googled it, and to my surprise, I found a Microsoft Connect support request about this made by a fellow Revit API developer ‘mikecvelide’. He was using Revit 2010 and found the debugger did not attach either. You can see the thread HERE. Microsoft did some investigation and it seems the problem is Visual Studio 2010 is using the .NET 4.0 debugger even though its a 3.5 or 2.0 application (I don’t believe Revit 2011 supports .NET 4.0 applications).

The workaround is this, edit your Revit.exe.config file which is located in the same directory as the Revit.exe and add:

<supportedRuntime version="v2.0.50727" />

Just before the </configuration> part of it. You should then be able to debug fine in Visual Studio 2010.

Note, v.2.0.50727 is the version I have installed, but you can check C:\Windows\Microsoft.NET\Framework for what the last few digits of your v2.0 folder is (even if you are developing for .NET 3.5 you still need to put in the 2.0 version number)

Friday, March 26, 2010

[Revit 2011] – Matt Masons What’s New Series

Every new Revit release, Matt Mason runs a series of blogs talking about the new features. They always provide a great overview and are well worth a read.

Make sure you check it out HERE.

[Revit 2011] – No more revit.ini for registering add-ins!

Can I get a hallelujah? It’s been a long time coming, but now it’s finally here! Anyone who has developed with the Revit API before will know you had to edit the clumsy Revit.ini file to add your tool. When doing so you had to be careful to set the right numbers and counts, and not overwrite any other developers tools. Well now you can forget all that!

In Revit 2011 there is a new XML based interface for registering your tools. The new .addin mechanism allows you to register your External Commands and External Applications using 1 or more xml files stored in the standard windows directories (AppData or ProgramData).

Here’s an example file in the new format to register two external commands:

<?xml version="1.0" encoding="utf-16" standalone="no"?>


<AddIn Type="Command">






<AddIn Type="Command">







This can be edited in notepad, and saved as WhateverILike.addin and stored in AppData or ProgramData (depending on whether you want it to be specific to the user or across anyone on the machine).

As you can see there, I’ve got two commands, registered easily in one .addin file. If I wanted to add another command later, I could either edit that file, or add a new .addin file! Most of the fields correspond to the old ini registration fields, except for ClientId, this is a GUID that is used to uniquely identify your add-in. You can get a GUID for your tool from here:

There are also a number of other properties and functionalities built in, such as setting the accessibility, icons, tool tip images etc, but have a look through the SDK documentation for information on those.

If this wasn’t easy enough, Autodesk have provided a dll file which can assist you with manipulating these files!

Thursday, March 25, 2010

[Revit 2011] – Massive Changes for the Revit API

My Handy USA Pacific Timezone clock in my Windows 7 Taskbar tells me that it’s ticked over to March 25 in the USA, which means the NDA has been lifted for Revit 2011 products.

Here are some of my highlights from the new API:

  • New FilteredElementCollector for better filtering of elements
  • New add-in registration me.chanism, no more Revit.ini fiddling!
  • Tighter integration with the Revit UI
  • You can now ask users to pick an object or a point.
  • Dynamic Model Update – changes to elements can raise an event, so you can run an add-in on a change to a certain element!
  • Performance updates across the board

There are so many more changes too, but those are my favourites so far.

For those that have already made tools for Revit 2010, the API namespaces have changed drastically, there is a lot more work than usual to be done to convert your tools over.

I plan on releasing some blog posts on the new features, as I’m sure some of the other Revit API bloggers are as well. I am very excited for the Revit 2011 release both in the API and the general program.

Wednesday, March 24, 2010

[General] – Blog Name + URL Change

I’ve now renamed the blog to simply ‘Rod Howarth’ as opposed to ‘Rod.NET’, which I decided was a little confusing (afterall, the URL is not Rod.Net)

I’ve also pointed my blogger account to go through – the old address and all links should still work (which is a great feature!) but now they will redirect to the updated URL.

Let me know if there is any issues as a result of this.

[Revit API] New Revit API Search Domain Name

GoDaddy were selling $2 domain names a couple of weeks ago, so I decided to register a domain for the Revit API Search Engine.

The URL is now

The old address will still work, but this should stop you from having to think of me every time you go to it :)

I’ve still been struggling to get the AUGI and Autodesk forums to be indexed by it (only the API sections), I think I may have made progress on the Autodesk forums, but the search engine is just not displaying anything from AUGI. Any Google Custom Search experts who know how to fix this, contact me!

Tuesday, March 23, 2010

[Revit API] Resource Guide – Free Download

At Autodesk University 2009 (call for proposals now open for 2010) I did a presentation on ‘How the Autodesk Revit API has saved our company time and money – and how it can do the same for yours’.

This presentation consisted two parts. First, I demonstrated a number of tools, we have made, and how they have helped our drafters, then secondly I presented all of the different resources I used to learn the API and how I utilized them.

To accompany the second part, I created a handout with links and information on all of the Revit API resources I knew of, and the order in which I would use them when creating a Revit program.

Jeremy Tammik suggested that I should upload this handout for others to make use of, which is a great suggestion. I must apologise to him as it had slipped my mind until recently. I’ve now edited it a little, and uploaded it to my web hosting, for anyone to download and pass onto others.

I realise that this is coming out a bit late in the Revit 2010 lifecycle, but I plan on updating it with any new information that comes out of Revit 2011, and will make a blog post about that when I do.

Here it is: Revit API Resource Guide by Rod Howarth

Let me know if there is any errors, or questions you have that relate to it.

Friday, March 19, 2010

[Revit] RemoteFX for Revit Remote Desktop farms?

Microsoft have announced Service Pack 1 for Server 2008 and Windows 7. Mostly just security updates, no new features, except this:

Microsoft RemoteFX – Supposedly allows great 3d graphics performance over Remote Desktop. This sounds like it could be perfect for running Revit ‘in the cloud’, or for remote access workers.

Monday, March 8, 2010

[Revit API] – How to edit add-ins while debugging without restarting Revit.

Jeremy Tammik posted this great timesaver on his blog that John Morse has developed. It cleverly uses a bridge DLL file to facilitate the reloading of your external tool DLL. Give it a go!

Friday, February 26, 2010

[Revit] How to make a web page that displays your standard keyboard shortcuts

As I’ve previous mentioned, the subscription pack for Revit 2010 introduced a new XML based methodology for setting up keyboard shortcuts.

In previous posts I’ve shown you what file to replace if you want to standardize this across your firm (we have a tool that users run which installs the latest API add-ins and copies the keyboard shortcuts file). I was recently asked to make a page which could display a listing of the latest keyboard shortcuts as a quick reference for our drafters to look or search through. The reason for this, is the inbuilt menu in Revit, whilst a massive step up from the text file, is not good for a quick glance over or print out.

Luckily, as the new system uses XML, this is was very easy for me to do.

I simply created a new ASP.NET web page on our intranet, with a gridview on it:

        <asp:GridView ID="GridView1" AllowSorting="true" runat="server" AutoGenerateColumns="False" 
            CellPadding="4" ForeColor="#333333" 
            GridLines="None" OnSorting="GridView1_Sorting">
            <RowStyle BackColor="#E3EAEB" />
                <asp:BoundField DataField="CommandName" HeaderText="CommandName" 
                    SortExpression="CommandName" />
                <asp:BoundField DataField="Shortcuts" HeaderText="Shortcuts" 
                    SortExpression="Shortcuts" />
                <asp:BoundField DataField="Paths" HeaderText="Paths" SortExpression="Paths" />
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#7C6F57" />
            <AlternatingRowStyle BackColor="White" />

There is a fair bit of extra code there for styling the control, but the main part is the bound fields.

And then in the code behind, I bound the XML file (which we have stored on a network drive) to the gridview like so:

        //create a dataset from the xml
        DataSet ds = new DataSet();

        //create it into a dataview and sort it via command name
        DataView view = new DataView(ds.Tables[0]);
        view.Sort = "CommandName";

        //bind the gridview to the dataview
        GridView1.DataSource = view;

And you will have a page which looks like this:


I’ve added sorting by using the AllowSorting=”true” property and binding to the event for sorting by using OnSorting=”GridView1_Sorting” as well has setting the SortExpression property in each BoundField.

The method that is called when the user tries to sort the gridview has the following code:

    protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
        DataView view = (DataView) GridView1.DataSource;
        view.Sort = e.SortExpression;

        GridView1.DataSource = view;

And there you have it – a live updating view of our company standard keyboard shortcuts XML file, great for educating drafters on shortcuts they may not have known about.

[Revit API] OleDB Jet Driver for interacting with Excel files in 64bit Revit

A common problem with 64bit development with Revit is the inability to use the Microsoft Jet OleDB driver to read and write to Excel files easily.

In the Getting Started With Revit API.doc file in the 2010 Revit SDK it states:

Note that there are some Microsoft components (such as OleDB provider for Microsoft Jet) that are not supported for 64-bit. All SDK samples are set up to work with either 32-bit or 64-bit Revit, except those samples that have dependencies to unsupported Microsoft components.

Basically, the problem has been that the 3rd party DLL file which is supplied by Microsoft did not have a 64bit version.

While this problem has not yet affected me in my development, I know a few people have mentioned it so I thought I’d pass on something I read today: How to get a x64 version of Jet? on MSDN blogs.

Apparently the beta of Office 2010 has the 64bit dll file everyone has been looking for, it is available HERE.

I hope this helps you out if you have run into this problem.