这是显示在revit api中获取的对象的execute方法,接下来是相关代码。无法获取对文档或应用程序对象的引用,这是我从ms visual stud中的错误报告中收集的内容。 我试过添加一个全局引用即。文件文件;与其他全局变量一起但是这并没有修改无引用错误。
public Result Execute(ExternalCommandData commandData,ref string message,ElementSet elements) { //获取应用程序和文档对象 UIApplication uiApp = commandData.Application; UIDocument uiDoc = uiApp.ActiveUIDocument;
try
{
Application app = uiApp.Application;
Document doc = uiDoc.Document;
... rest of code not included
//mouse button click event
public void btn1_Click(object sender, EventArgs e)
{
//call to method using the Document doc revit api handle
MethodThatRequiresDoc(doc);
}
MethodThatRequiresDoc(Document doc);
{
//Call to copy and paste between docs new revit 2014 method
CopyPasteMassesBetweenDocs(doc, app);
}
答案 0 :(得分:1)
查看ExternalEvents
framework的文档。基本上,您不会在Document
事件处理程序中获取btn1_Click
实例。相反,您引发ExternalEvent
并且所调用的处理程序的签名将包含对Document
的引用。
Jeremy Tammik撰写的这篇博文可能有所帮助:http://thebuildingcoder.typepad.com/blog/2013/12/replacing-an-idling-event-handler-by-an-external-event.html