2

This is the execute method to show the objects obtained in the revit api, following that is the code in question. The reference to the document or application objects cant be obtained, this is what I have gleaned from the error report in ms visual stud. I have tried adding a global reference ie. Document doc; in with the other global variables however this didn't amend the no reference error.

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { //Get application and document objects 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);
    }
Bimtopian
  • 37
  • 1
  • 5

1 Answers1

1

Check the documentation for the ExternalEvents framework. Basically, you will not obtain a Document instance inside the btn1_Click event handler. Instead, you raise an ExternalEvent and the signature of the handler called will include a reference to the Document.

This blog entry by Jeremy Tammik might help: http://thebuildingcoder.typepad.com/blog/2013/12/replacing-an-idling-event-handler-by-an-external-event.html

Daren Thomas
  • 67,947
  • 40
  • 154
  • 200