开发者

How to create Revit add-in Windows installer in Visual Studio 2008

开发者 https://www.devze.com 2023-01-26 19:19 出处:网络
Process of manuall开发者_如何学运维y installing a Revit 2011 add-in: Put add-in DLLs in desired location, for example C:Program Files\\RevitAddin\\RvtAddin.dll

Process of manuall开发者_如何学运维y installing a Revit 2011 add-in:

  1. Put add-in DLLs in desired location, for example C:Program Files\RevitAddin\RvtAddin.dll
  2. Create .addin xml file that contains information about add-in (location, full class name, etc.). This ".addin" file must be placed in one of the following locations:
    • For Windows 7: C:\ProgramData\Autodesk\Revit\Addins\2011\
    • For Windows XP: C:\Documents and Settings\All Users\Application Data\Autodesk\Revit\Addins\2011\

I can easily accomplish the first step with a Visual Studio 2008 Setup Project. For second step, I probably need to use Custom Action that would create xml .addin file. I don't know how to pass information(output location) from an installer to Custom Action.


Open up the custom actions editor where you will see folders for each phase of installation or uninstallation (Install, Commit, Rollback, Uninstall). Under each folder you will add references to your custom actions.

Select one of these custom actions and look at the properties. There will be a property called CustomActionData which is where you map values from the installer to the custom action.

An example of the format of this property is shown below.

/installLocation="[ProgramFilesFolder][ProductName]" /setting1="[SETTING1]"

Then inside your custom action class you can write the following to access this values

string path = this.Context.Parameters["installLocation"];
string setting1 = this.Context.Parameters["setting1"];

Also you shouldn't be referencing an absolute path when writing the Revit addin file. Instead you can do the following to find the AppData folder regardless of what OS is being used.

private string AddInManifestPath()
{
    string appdata = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData);
    string path = System.IO.Path.Combine(appdata, @"Autodesk\REVIT\Addins\2011\DVAMC.addin");
    return path;
}


Thanks for the answer, Eric. I already solved the problem.

Regarding custom actions, I did it pretty much how you described it.

I also had problem with Installer class of my custom action. I needed to put it in separate project, otherwise I got 1001 error during installation.

As for addin file, I determined its path using RevitAddinUtility. RevitAddInUtility.dll is a .NET utility class assembly which you can find in the Revit Program folder. It provides you with methods for creating addin file and determining path of Revit addins folder.

Thanks again for your answer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号