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: 

How to load Revit file in API using C#?

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

How to load Revit file in API using C#?

I want to load the *.api file in C# code. I am trying to export the images from Revit file for specific views in the c# application. The issue is to get the ExternalCommandData from the revit (*.rvt) file.

 

public Autodesk.Revit.UI.Result Execute(ExternalCommandData revit,
   ref string message, ElementSet elements)
    {
      UIApplication uiapp = revit.Application;
    }

I want to browse *.rvt file and call above method from the Windows form.

 

Please help asap.

Thank You

5 REPLIES 5
Message 2 of 6
jeremytammik
in reply to: Anonymous

Dear Pravin,

 

Thank you for your query.

 

Calling directly into the Revit API from an external context is, was and always has been illegal.

 

The Revit API cannot ever be used except within a valid Revit API context.

 

Such a context is provided exclusively by Revit call-back methods.

 

You need to subscribe to a Revit event, such as an external command Execute method.

 

Within the event handler, the Revit API can be used.

 

You can also use the Revit API to set up an external event that can be raised from a non-Revit-API context, such as your standalone external application.

 

This is demonstrated by the ModelessDialog/ModelessForm_ExternalEvent SDK sample.

 

This question has been answered and discussed in depth numerous times in the past, both in the Revit API discussion forum and by The Building Coder.

 

Many examples and further explanations are provided in The Building Code topic group on Idling and External Events for Modeless Access and Driving Revit from Outside:

 

 

Here are some of the Revit API forum discussion threads addressing similar issues:

 

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 6
Anonymous
in reply to: jeremytammik

Hi ,
Let me explai what I am trying to do.
I have houses that have been built with different materials. So for eg. Same house can have a double window or a single window, multiple types of floorings etc.
Now the client wants to have the images of every view with the materials selected by him.
1. So some how, the inputs I will have is the materials selected.
2. Based on the materials/options selected, i want to take images of the views (the front, back, side and top)
3. Export the images in a pdf and email it to the client.


Now the above happens over a website. So the options selected for the house is stored somewhere on the DB and using those selections i want to get images from revit.

I want this as a automation process will work automatically from the c#.

Is this possible and how do I approach this problem.

Thanks.

Message 4 of 6
jeremytammik
in reply to: Anonymous

Thank you for your clarification.

 

My answer remains unchanged.

 

It covers all your needs.

 

I wish you lots of fun and success exploring and implementing your add-in!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 6
Anonymous
in reply to: jeremytammik

Hi,

I will create a plugin for this, but can we use this plugins for the REVIT Server?

Message 6 of 6
jeremytammik
in reply to: Anonymous

If all you want to do is export images from the RVT or RFA file, your needs may already be completely covered by Forge.

 

For full details on how and why, please refer to my blog post on External Access to the Revit API.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

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

Post to forums  

Autodesk Customer Advisory Groups


Rail Community