2

这是显示在 revit api 中获得的对象的执行方法,下面是有问题的代码。无法获得对文档或应用程序对象的引用,这是我从 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);
    }
4

1 回答 1

1

检查ExternalEvents框架的文档。基本上,您不会在事件处理程序中获得Document实例。btn1_Click相反,您提出一个ExternalEvent并且调用的处理程序的签名将包括对Document.

Jeremy Tammik 的这篇博文可能会有所帮助:http ://thebuildingcoder.typepad.com/blog/2013/12/replacing-an-idling-event-handler-by-an-external-event.html

于 2014-05-20T08:14:47.717 回答