Exporting .MAJ files using Revit API

Exporting .MAJ files using Revit API

fpmalard
Advocate Advocate
550 Views
3 Replies
Message 1 of 4

Exporting .MAJ files using Revit API

fpmalard
Advocate
Advocate

I need to implement a C# Plugin in Revit 2023 and export multiple Assemblies to .MAJ files without asking for an export folder path for each assembly.

It seems, from what I was able to find, this use to be possible in Revit 2019 through a method ExportToMAJ() as mentioned here:
https://www.revitapidocs.com/2019/14c832e6-eb76-774b-1b75-acf03de6438c.htm

I couldn’t find an alternative supported by the latest version. It seems this portion of the Revit API was migrated to an external plugin and now it isn't available anymore inside default Revit API:

 

https://help.autodesk.com/view/RVT/2024/ENU/?guid=GUID-4D0D796A-EDE6-4A36-8D3C-FD898975C378

 

I would like to explore some alternatives if anyone can confirm it works:

 

a) Creating MAJ files directly (it doesn't look like MAJ is a public documented file format)

b) Adding the external plugin DLL to the C# solution and access these classes (it could be something not supported officially and not future-proof)

c) Using the PostCommand() mechanism which can call the MAJ export command but wouldn't avoid the .MAJ file save dialog to pop up

d) Using the Journal mechanism to mimic the export command without exposing the MAJ export dialog

 

Any other possibilities you may suggest?

 

Thank you.

0 Likes
551 Views
3 Replies
Replies (3)
Message 2 of 4

jeremy_tammik
Alumni
Alumni

Thank you for raising the question here in public for all to chip in.

  

As I mentioned in our preceding private email conversation, the journal file approach may possibly offer the easiest solution.

    

All you need to do is to ensure that you have recorded a journal file that performs the necessary steps on a specific BIM. The, if you can swap in another BVIM in its place, it enables you to repeat the same sequence of steps with the same user input. I used that a couple of times in the past, renaming the input BIM and the output files in order to preserve the exact steps and UI input required for the process. Check them out in The Building Coder journal category:

   

   

Please let us know how you end up solving this. Thank you!

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 4

fpmalard
Advocate
Advocate

Hi Jeremy,

 

Do we need to close/open Revit for each Journal processing?

 

From my limited experience with journal files, it seems you can only run them while starting Revit up.

The ideal workflow would be:

 

- Determine the Journal script text for exporting a single Assembly to MAJ

- Determine the assemblies to export

- For each Assembly, hack the Journal script and execute it to create the MAJ file

 

Is this workflow achievable within a running Revit session?

 

Thank you.

0 Likes
Message 4 of 4

jeremy_tammik
Alumni
Alumni

>  Do we need to close/open Revit for each Journal processing?

  

Yes. So this approach is strictly for a fully automated batch driven system, overnight or whatever.

  

The approach you describe is one possibility. The one I used in my experiments pointed to above was different. Instead of manipulating the journal file, I simply hard-coded one single RVT project name and copied each file that wanted processing to that location, then copied the result out of there again.

  

> Is this workflow achievable within a running Revit session?

  

Dunno; doubt it; try it out and let us know. Thx. Happy weekend!

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes