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
Solved! Go to Solution.
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...
ErrorProvider
class, Validating
and Validated
eventsSystem.Configuration.ApplicationSettingsBase
classJavaScriptSerializer
classThe entire add-in project is available from the ExportWaypointsJson GitHub repository, and the version discussed here is release 2017.0.0.11.
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"
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.