如何在 Visual Studio 2008 中创建 Revit 插件 Windows 安装程序

发布于 2024-10-04 10:41:21 字数 488 浏览 0 评论 0原文

手动安装 Revit 2011 附加模块的过程:

  1. 将附加模块 DLL 放置在所需位置,例如 C:Program Files\RevitAddin\RvtAddin.dll
  2. 创建 .addin xml 文件,其中包含有关附加信息的信息在(位置、班级全名等)。此“.addin”文件必须放置在以下位置之一:
    • 对于 Windows 7:C:\ProgramData\Autodesk\Revit\Addins\2011\
    • 对于 Windows XP:C:\Documents and Settings\All Users\Application Data\Autodesk\Revit\Addins\2011\

我可以轻松完成第一步是 Visual Studio 2008 安装项目。 对于第二步,我可能需要使用自定义操作来创建 xml .addin 文件。我不知道如何将信息(输出位置)从安装程序传递到自定义操作。

Process of manually 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寒冷纷飞旳雪 2024-10-11 10:41:21

打开自定义操作编辑器,您将在其中看到安装或卸载每个阶段(安装、提交、回滚、卸载)的文件夹。在每个文件夹下,您将添加对自定义操作的引用。

选择这些自定义操作之一并查看属性。将有一个名为 CustomActionData 的属性,它是您可以在其中将安装程序中的值映射到自定义操作。

该属性的格式示例如下所示。

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

然后在自定义操作类中,您可以编写以下内容来访问此值

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

另外,您不应该引用绝对值写入 Revit 插件文件时的路径。相反,无论使用什么操作系统,您都可以执行以下操作来查找 AppData 文件夹。

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;
}

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;
}
最初的梦 2024-10-11 10:41:21

谢谢你的回答,埃里克。我已经解决了这个问题。

关于自定义操作,我几乎按照您的描述进行了操作。

我的自定义操作的安装程序类也有问题。我需要将它放在单独的项目中,否则在安装过程中会出现 1001 错误。

至于加载项文件,我使用 RevitAddinUtility 确定了其路径。 RevitAddInUtility.dll 是一个 .NET 实用程序类程序集,您可以在 Revit 程序文件夹中找到它。它为您提供了创建插件文件和确定Revit插件文件夹路径的方法。

再次感谢您的回答。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文