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: 

Launch Revit.exe with custom parameter

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
1491 Views, 3 Replies

Launch Revit.exe with custom parameter

Hello everybody,

 

For a new project I need to create an addin that can have access to the custom parameters given after "Revit.exe" call.

 

As described here (https://thebuildingcoder.typepad.com/blog/2019/01/face-methods-and-custom-command-line-arguments.htm... I call the exe file in this way : "C:\Program Files\Autodesk\Revit 2021\Revit.exe" "C:\temp\test.rvt" ---- C:\temp\test.txt

 

My question is : how to get the parameters from code ? (public Autodesk.Revit.UI.Result OnStartup(UIControlledApplication ui_controlled_application))

 

Thanks a lot

3 REPLIES 3
Message 2 of 4
jeremytammik
in reply to: Anonymous

You can check whether System.CommandLine works for you in your add-in.

 

However, I would recommend not even trying, and just using a text file to pass in whatever information your add-in requires. Leave the command line to Revit.exe. It is not yours to interfere with. You can use INI, JSON, XML format, or just human readable text, or whatever you like.

 

https://thebuildingcoder.typepad.com/blog/2016/09/hololens-escape-path-waypoint-json-exporter.html

 

> I also implemented two different approaches to store the user-defined add-in option settings, in XML and JSON...

 

  • Subsidiary external settings command
    • Display modal Windows form
    • Implement form validation using ErrorProvider class, Validating and Validated events
    • Store add-in option settings in XML using the .NET System.Configuration.ApplicationSettingsBase class
    • Store add-in option settings in JSON using custom solution and JavaScriptSerializer class

The entire add-in project is available from the ExportWaypointsJson GitHub repository, and the version discussed here is release 2017.0.0.11.

  



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

Message 3 of 4
Anonymous
in reply to: Anonymous

Thank you Jeremy for your help. I really appreciate.

 

In fact I don't really need to export / import data. What I need is just to sent some parameters to my Addin at Revit launch.

 

So to resume the solution :

 

I call Revit this way :

 "C:\Program Files\Autodesk\Revit 2021\Revit.exe" "C:\temp\test.rvt" ---- C:\temp\test.txt

 

I obtain the parameters in the code this way :

string[] arguments = Environment.GetCommandLineArgs();
string my_config_file = arguments[3] // Equals "c:\temp\test.txt"

 

Message 4 of 4
Anonymous
in reply to: Anonymous

If you don't need to open a file at startup you can also lanch Revit in this way :

"C:\Program Files\Autodesk\Revit 2021\Revit.exe" /C:\temp\test.txt

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

Post to forums  

Forma Design Contest


Rail Community