Message 1 of 3

Not applicable
07-03-2014
07:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
Solved! Go to Solution.