Wednesday, December 23, 2009

Adding your plugin to the [ExternalApplications] section of Revit.ini

For the installer for RevitPythonShell, I need to programmatically add the plugin to the [ExternalApplications] section of Revit.ini. Instead of writing a one-off solution, I decided to create a little commandline tool that can be reused for my next project or even your project: addrevitplugin.exe. You can look at the source too!
The tool is written using AutoIt v3, a BASIC derivative with lots of useful functions for automating windows tasks. Expect to see some more samples of such scripts on this blog...
The commandline options to addrevitplugin.exe are:
  • EAClassName: This corresponds to the key "EAClassName#" in the Revit.ini file
  • EAAssembly: (optional) This corresponds to the key "EAAssembly#" in the Revit.ini file and is the full path to the .NET assembly containing the plugin class.
Using addrevitplugin.exe, you can either add, update or delete a plugin entry in the "ExternalApplications" section. By specifying EAClassName without EAAssembly, the corresponding plugin is deleted from Revit.ini. If EAAssembly is provided, then the plugin is either added (if it was not yet installed) or updated with the assembly.

I also use this tool in conjunction with Launchy to quickly switch between environments when developing Revit plugins: Create a batch file for each location of your plugin (Debug, Release, Installed) with contents similar to:

addrevitplugin.exe RevitPythonShell.RevitPythonShellApplication "C:\Projects\revitpythonshell\RevitPythonShell\bin\Debug\RevitPythonShell.dll"

Make sure the second argument is enclosed in double quotes if it contains spaces. Create a separate file for each environment.

I named the files debug_RevitPythonShell.bat, release_RevitPythonShell.bat and installed_RevitPythonShell.bat. By saving these files in a directory scanned by Launchy, I can quickly switch between the environments before starting Autodesk Revit Architecture 2010.

Note:If you are not using Autodesk Revit Architecture 2010 on a 32bit system, you will want to change the GUID used to look up the install path in the script addrevitplugin.au3. You will then need to recompile the script using Aut2Exe.exe, which can be obtained from the Auto It website.

Update: I have renamed addrevitplugin.exe to rac32plugin.exe and rac64plugin.exe so that now a 32-bit and a 64-bit version comes precompiled. Also, the scripts have changed somewhat. Please check the project website.

No comments:

Post a Comment