Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Accessing model information without needing to open Revit

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
travis.rothbloom
543 Views, 2 Replies

Accessing model information without needing to open Revit

Hi,

 

I’m trying to create a console application that can read data from a Revit model without having to open Revit. Compiling the code works just fine, but when I try to run it, I get a System.BadImageFormatException saying that the RevitAPI.dll module or one of its dependencies couldn’t be found. Might this be because I’m creating this as a console application rather than the standard class library we use for addins?

Here’s the code I’m using as reference:

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Autodesk.Revit.UI;
using Autodesk.Revit.DB;

namespace extractFromClosedRevitFile
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            Autodesk.Revit.ApplicationServices.Application revitApp =
new Autodesk.Revit.ApplicationServices.Application(); OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.Cancel) { return; } Document doc = revitApp.OpenDocumentFile(ofd.FileName); Console.WriteLine(doc.Title); Console.ReadLine(); } } }

 

Thanks,
Travis

 

2 REPLIES 2
Message 2 of 3

I am sorry, Travis, you cannot do what you want to do. You cannot instantiate a Revit Application. It is an application singleton and is instantiated by a Revit initialization procedure during Revit start-up. In other words – in order for you to use the Revit API, Revit must be launched and running.

Arnošt Löbel
Message 3 of 3

Thanks for responding so quickly Arnošt, it's unfortunate that this isn't possible but I understand.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community