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: 

Revit API code without user interaction in application

18 REPLIES 18
Reply
Message 1 of 19
inayath
4069 Views, 18 Replies

Revit API code without user interaction in application

Hi,

 

I browsed and followed some post and learned few basic Revit API code as JeremyTammik advice on my previous post. 

 

What I learned and done is this, creating some addin to Revit API from C# and include into REVIT, my code will be called while user interaction is takes place in Revit Application.

 

But What I need is to access the Revit project properties without the user interaction on REVIT. I mean my C# code should work independently.

 

Note: All I need is to access the Revit project properties(FileName and location which is opened in Revit)

 

Please let me know what should I learn for this. And kindly share your better ideas. (Any links or Sample code will be better).

 

 

Thanks & Regards,

Jayahar

18 REPLIES 18
Message 2 of 19
R.van.den.Bor
in reply to: inayath

This blog is very usefull if you want to open a revit file without revit.

 

http://thebuildingcoder.typepad.com/blog/2010/06/open-revit-ole-storage.html

 

With some modification to this tool, you can even read the parameters stored in the family or project file.

 

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 3 of 19

Dear Remy,

 

Thank you for the suggestion, but...

 

I am sorry to say that as far as I know your statement is incorrect.

 

I am not aware of any way at all to read parameter values from a Revit project without going through the official Revit API.

 

Afaik, the OLE structured storage approach only provides access to a limited set of file metadata, such as date and version number.

 

Sorry.

 

I would love to stand corrected, so if you actually can extract parameter data from a Revit model without using the Revit API, I am sure we would all love to see a working example of that.

 

Thank you!

 

Cheers,

 

Jeremy



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

Message 4 of 19
Revitalizer
in reply to: inayath

Hi,

 

just subsribe to one of the many available events, e.g. ControlledApplication.DocumentOpened.

 

There you can access the document and its ProjectInfo object, if existing.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 5 of 19
jeremytammik
in reply to: inayath

Dear Jayahar,

 

Thank you for your interest.

 

This is one of the most frequently asked questions on the Revit API, and has therefore been answered hundreds of times over in the past, both here in the discussion forum and by The Building Coder.

 

It is covered in full including many examples and reams of sample code by The Building Coder topic group on Idling and External Events for Modeless Access and Driving Revit from Outside:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.28

 

I just updated that list with the newest entries just for you.

 

Best regards,

 

Jeremy



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

Message 6 of 19

Oh, I'm sorry, I misread. you can't for project (rvt) files, but you can for families (rfa).

There is a part called PartAtom which holds parameter information, as long as the parameter in the family have a value.

 

 

 

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 7 of 19

Ah, sounds very cool. Any sample code on using that?

 

Cheers,



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

Message 8 of 19

What I did was, use the tool from this blog:

http://thebuildingcoder.typepad.com/blog/2010/06/open-revit-ole-storage.html

 

In there is a class called BasicFileInfo.cs. 

 

It has a function called  public void ReadStructuredStorageFile()

 

I did some testing here and expanded this function to read the parameters.

 

Like you can see in the structured storage viewer, the PartAtom is stored as a XML, so anyone who can read xml files, knows what to do 🙂

 

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 9 of 19

Dear Remy,

 

Thank you very much for the reminder.

 

I see that this was covered by The Building Coder:

 

http://thebuildingcoder.typepad.com/blog/2009/11/extract-part-atoms.html

 

http://thebuildingcoder.typepad.com/blog/2010/09/extract-part-atom-revisited.html

 

A sample external command even made its way into The Building Coder samples:

 

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/C...

 

So this RFA parameter data is also accessible without entering Revit and using the API?

 

Cool!

 

Cheers,

 

Jeremy



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

Message 10 of 19

Yes, that's the beauty of it.

 

You can just make a windows forms app on a PC without having revit installed. You can retrieve all kinds of information, like category of the family, parameters, thumbnail, Revit version ect.

 

Too bad it doesn't work for rvt files, but I hope to meet you next week at Munich and by then I'm confident you have a solution for this aswel 🙂 🙂 🙂 🙂 :).

 

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 11 of 19

Dear Remy,

 

Looking forward to meeting you in Munich!

 

I am pretty sure this is one issue I will not be able to add anything new to.

 

I hope you have some nice juicy cloud related stuff to discuss as well as the standard Revit topics  🙂

 

Cheers,

 

Jeremy



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

Message 12 of 19
Revitalizer
in reply to: jeremytammik

Hi Jeremy & Remy,

 

you can open a family file in a text editor...

 

By the way, I really think that the thread poster just wants to avoid user interaction, no popping up dialogs and so on.

All in an add-in context.

 

 

Rudi

Edit: I'm in Munich, too 🙂




Rudolf Honke
Software Developer
Mensch und Maschine





Message 13 of 19
R.van.den.Bor
in reply to: Revitalizer

cool, didn't know that. Everything is klingon except for the parameter part, that's displayed as internal xml.
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 14 of 19
OR_AND_NO
in reply to: R.van.den.Bor

Could You please show an example access to revit parameters without revit api 

Message 15 of 19
inayath
in reply to: OR_AND_NO

Hi All,

 

I have a requirement that, I need to saveAs the working file (whatever file) opened on Revit application which is idle for some minutes. I done the idle timing things in C#.

 

Now all I need is to SaveAs the working revit file with new name in C# without going to Revit application. which means I should not save from Revit instead from C#. It is doesn't matter that with or without Revit API.

 

As I'm experienced only in dotnet, and very newer to entire Autodesk products I've no idea with this.

 

So expecting for suggestion on how could I do that.? Now you all will be clear on what I'm asking. Right.

 

 

Thanks,

Jayahar

Message 16 of 19
jeremytammik
in reply to: inayath

Dear Jayahar,

 

Glad to hear you are experienced in .NET programming.

 

Then you will have no problem understanding the situation and following the steps described in The Building Coder topic group on Idling and External Events for Modeless Access and Driving Revit from Outside:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.28

 

I just updated that list with the newest entries just for you.

 

Best regards,

 

Jeremy



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

Message 17 of 19
inayath
in reply to: jeremytammik

Hi Jeremytammik,

 

Thanks for the post, I followed it and found the sample application(RevitWebCam), with this I can able to understand the code. 

 

But, still I cannot able to run this. It throwing syntax errors also. I believe this might be the version compatibility. The code I downloaded is based on Revit 2013 or lesser. I'm having Revit 2016. 

 

If this is not Version issue, then the way I'm running is wrong. Can you please guide me on how could I execute this 'External events' ?

 

Note: I should not depend on user interaction with Revit, The C# code needs to do all stuff.

 

 

Regards,

Jayahar

Message 18 of 19
jeremytammik
in reply to: inayath

Dear Jayahar,

 

I suggest that you do a bit more reading before you jump into hacking.

 

The errors you are encountering are indeed due to migration issues.

 

Both the Revit SDK and The Building Coder provide other samples for implementing external events that are much simpler than the RevitWebCam one, as well as being up to date.

 

I hope this helps.

 

Furthermore, please do not send me private messages to try to speed up my answers.

 

It will not help.

 

Thank you for your understanding. 

 

Cheers,

 

Jeremy



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

Message 19 of 19
jeremytammik
in reply to: jeremytammik

Published a summary of this thread on The Building Coder:

 

http://thebuildingcoder.typepad.com/blog/2016/02/reading-an-rvt-file-without-revit.html



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 DevCon in Munich May 28-29th


Rail Community