Friday, September 30, 2011

[Revit Server]– How to get a listing of all Revit Server projects through the REST interface

I’ve been writing some code that utilizes the Revit Server REST API, and in particular, I’m working on a HTML replacement for the Revit Server Admin page, which is currently written in Silverlight. More details on that will come (and will be included in my AU virtual class), but for now I ran into a bit of a stumbling block that others may encounter.

The REST API has an endpoint that lets you list the contents of a certain folder. This endpoint requires a GET request to the path ‘/{folderpath}/contents’ with folderpath being the path of your folder, for example a request to ‘/My_Project/contents’ would list the contents of the My_Project folder. But how do you find out that there is a My_Project folder in the first place? You need to get a listing of all of the folders underneath the parent folder on the server, but how would you do that? You can’t send you request to ‘/contents’, as you are missing the folder path section, and thus it’s not a valid endpoint according to the API. I tried a number of different combinations of URL’s before I finally found one that seems to work.

To get a listing of all the folders underneath the parent folder, send your GET request to:

‘/ /contents’

That is, use a space instead of a folder path, like so:

http://localhost/RevitServerAdminRESTService/AdminRESTService.svc/ /contents”

This will be treated as if it is the root folder, and will list the folders underneath that.

[Revit]– Autodesk University 2011 Virtual Class: Automating Autodesk Revit Server

The Autodesk University conference in Las Vegas is approaching us once again. I’ve had the great privilege of presenting at this event for the past two years on topics concerning the Revit API. At this stage it doesn’t look like I’ll be making the trip from Australia this year to attend the physical conference, but that hasn’t stopped me from being involved virtually! I’ve been accepted to present a class on “Automating Autodesk Revit Server”.  Here is the class description:

Class Description

The latest version of Revit Server offers a number of automation capabilities, from locking files and creating directories to generating a new local file for a Revit central model. This class will explore these options and consider some scenarios where they can be leveraged along with existing Microsoft® Windows® and Revit APIs to perform time-saving tasks. A number of examples will be showcased, including how to create a HTML replacement for the Silverlight® admin tool, how to create a Revit Server folder from an existing system, and how it is possible to have a scheduled task that runs once a day, creates a local file, opens it, and exports the model to a DWF™ without user interaction.

Key Learning

  • Explain how Revit server automation can be integrated into existing software processes
  • Describe the REST interface to Revit Server
  • Combine the Revit Server command line and the Revit API to perform a task in a Revit model on a schedule
  • Use the supplied command line utilities to automate Revit Server

The idea for this class came about when I was playing around with Revit Server and noticed that there is a document on the REST API in the Revit SDK. I had a few ideas for interesting things to do with this API, and Revit Server in general, and what better motivation to put them into action than the pressure of presenting an AU class on the topic :)

Virtual classes only go for 45 minutes, so the code will mostly be read through and explained rather than written live, but I’ll have a bunch of code available for download and in the handout.

If you are interested in Revit Server, be sure to check it out! If you aren’t, but are interested in Revit API development, check out the various other Revit API classes that will be a part of the event, the Revit API team have once again put together a great curriculum to help you get as much API knowledge as you can out of AU.