我正在尝试实现一个 Revit ADDIN,它在启动时完成一个过程。目前我正在尝试在 Revit 启动后立即加载一个 revit 文件,我只想了解如何创建一个在启动时完成的插件。
程序启动正常,文件之间没有任何连接问题,但没有任何反应……没有文件自动加载但没有错误?
我不确定我会在哪里出错,据我所知,这会自动启动我的 Revit 文件?*忽略分配给程序的无关名称
Class1.cs
using System;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Events;
using Autodesk.Revit.UI;
using System.Reflection;
namespace AreaChecker
{
class Class1 : IExternalApplication
{
const string _test_project_filepath
= "c:/Users/Test/Desktop/Forge/models/123.rvt";
public Result OnStartup(UIControlledApplication a)
{
a.ControlledApplication.ApplicationInitialized
+= OnApplicationInitialized;
return Result.Succeeded;
}
void OnApplicationInitialized(
object sender,
ApplicationInitializedEventArgs e)
{
// Sender is an Application instance:
Application app = sender as Application;
// However, UIApplication can be
// instantiated from Application.
UIApplication uiapp = new UIApplication(app);
uiapp.OpenAndActivateDocument(
_test_project_filepath);
}
public Result OnShutdown(UIControlledApplication a)
{
return Result.Succeeded;
}
}
}
区域检查器.ADDIN
?xml version="1.0" encoding="utf-8" standalone="no"?>
<RevitAddIns>
<AddIn Type="Application">
<Name>AreaChecker</Name>
<Assembly>C:\Users\Test\source\repos\AreaChecker\AreaChecker\bin\Debug\AreaChecker.dll</Assembly>
<AddInId>d48038f8-ba7c-4894-818d-3f8bef5f802d</AddInId>
<FullClassName>AreaChecker.Class1</FullClassName>
<Text>AreaChecker.Class1</Text>
<VendorId>NAME</VendorId>
<VendorDescription>Your Company Information</VendorDescription>
</AddIn>
</RevitAddIns>
注意:我对 Revit Command Addin 相当熟悉,但不是应用程序,所以我了解类和插件文件之间通过 dll 的连接