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: 

Trying to access Revit COM from Console Application using C#.net

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
1274 Views, 5 Replies

Trying to access Revit COM from Console Application using C#.net

I'm writing a console application in C#.net and I was hoping to access the Revit API's by including them as references.  I can code OK (all the autocorrect works and finds the contents of the libraries), but when I run the code, it crashes saying I have a x86 or x64 issue.  I found other pages showing how to resolve this, but nothing seems to work for me (in either 32- or 64-bit configurations ) 

 

But my question isn't really how to resolve that, but rather why am I getting this error?  I'm working with all 64-bit API's, so why is there any issue?  I would think that referencing a 64-bit Revit API on a 64-bit console application would be compatible. 

 

So, can I even access the Revit COM from a console application? 

 

And, if I can access Revit, how can I get rid of this x64 x86 issue? 

5 REPLIES 5
Message 2 of 6
gopinath.taget
in reply to: Anonymous

Hello,

 

Can you please give more information on the actual issue? i.e., is there an error message or exception message?

 

Revit does not have a COM API anymore so I am not sure how you are using the Revit API in an external application.

 

More details about the what you are doing with the API would help.

 

Best Regards

Gopinath

Message 3 of 6

Few questions come to mind: Have you tried copy local = false for both dlls? Are you running the correct .NET framework version ?
Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 4 of 6
Anonymous
in reply to: Anonymous

I guess if there is no COM API, then that resolves the issue. Any reasons why they don't have COM access?  Seems like a terrible lack of functionality. 

 

Just to confirm, something like this isn't possible:

 

            Autodesk.Revit.ApplicationServices.Application RevitApp;
            RevitApp = (Autodesk.Revit.ApplicationServices.Application)Marshal.GetActiveObject("REVIT.Application");

 

I'm using 4.0 .net. 

 

 

Message 5 of 6
gopinath.taget
in reply to: Anonymous

Hello,

 

There was a COM based API for Revit many releases ago but we do not have one anymore. The supported API is a .NET API and it has to run in-process inside Revit. If you could describe what you are trying to achive, I may be able to suggest some alternatives.

 

Best Regards

Gopinath

Message 6 of 6
Anonymous
in reply to: gopinath.taget

There isn't much to say, since if you say COM access is impossible, then I don't have any recourse.  I'm trying to create a C# console Application.  That won't work without COM access. 

 

Strange, I can access CATIA and Rhino without issue.  This is a bummer that Revit isn't as useful in this sense.  I'd much rather code my stuff in a simple-to-use EXE, rather than have my clients try and install the crappy addin stuff into their session of Revit. 

 

Moving forward, I'll just have to recompile my code as a Revit plug-in, and access CATIA and Rhino via COM from Revit.  I assume that is doable. 

 

 

 

 

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