Monday, 24 November 2008

Opening a file in Revit

A simple place to start!

A fundamental requirement of some of the software I build is to open Revit files, present them to the user, ask the user to do some things to it, save and close the file, and then open another. Trying to open a Revit file is where I started many months back and boy was I disappointed; I wondered at this point if the API was going to be able to meet any of our needs. Perhaps my expectations were too high having worked with the mature AutoCAD API.

You can indeed open existing Revit files using the following:

Application.OpenDocumentFile(filename)


But this doesn't present the file to the user. You can't see it or access it, the file is waiting to be altered programatically, not by a human.

Apparently this functionality is on the wish-list, having been requested multiple times, so until then if you need to open a file for a user, you need to 'botch' it by asking Windows to open it:

Process.Start(filename)


Assuming the host machine knows what to do with a .rvt file, then your file will open up into Revit. And then you can use ActiveDocument to manipulate/save/close etc.

No comments:

Post a Comment

Comments are moderated, so you'll have to wait a little bit before they appear!