<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Updating a form from an ExternalEvent handler in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/7066155#M59748</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanx I did the same thing with a winform, I added myForm to the ExtEvent handler, so far it has worked well, I can now use multiple buttons and refresh and keep the form alive whilst the user edits the model in between transactions initiated from the external event!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// We give the objects to the new dialog;&lt;BR /&gt;// The dialog becomes the owner responsible for disposing them, eventually.&lt;BR /&gt;m_MyForm = new Fam_DGV_Form(uiapp, exEvent, handler);&lt;BR /&gt;&lt;BR /&gt;//Add the form to the handler, so that the form can be updated from the externalEvent class(the handler)&lt;BR /&gt;handler.FormThing = m_MyForm;&lt;/P&gt;&lt;P&gt;m_MyForm.Show();&lt;/P&gt;</description>
    <pubDate>Sat, 06 May 2017 08:48:54 GMT</pubDate>
    <dc:creator>n_mulconray</dc:creator>
    <dc:date>2017-05-06T08:48:54Z</dc:date>
    <item>
      <title>Updating a form from an ExternalEvent handler</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/6935614#M59742</link>
      <description>&lt;P&gt;I have a situation where a form is raising an External Event and then an External Event Handler is making some changes to the Revit model.&lt;/P&gt;&lt;P&gt;The form is basically a list of rooms in the model and when the user makes a selection then the room object is changed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is: how can the form then be updated with the changes to the room? I can't see anyway for the External Event handler to 'talk' back to the form.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 21:42:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/6935614#M59742</guid>
      <dc:creator>sean_dodsworth</dc:creator>
      <dc:date>2017-03-09T21:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: Updating a form from an ExternalEvent handler</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/6938627#M59743</link>
      <description>&lt;P&gt;Dear Sean,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are many possible solutions for this, and they completely independent of the Revit API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your external event Execute method, you have access to a valid Revit API context and can query and modify the BIM as you please.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From that context, you can use any kind of inter-process communication you like to transport any information you like back to your modeless form.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually, since the modeless form can be managed by the same process as the external event, there is no need for inter-process at all, you are in the same process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance, your modeless form can implement some public methods that can be called from within the external event Execute method to talk back to it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 22:09:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/6938627#M59743</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-03-10T22:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: Updating a form from an ExternalEvent handler</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/6940733#M59744</link>
      <description>&lt;P&gt;Hi Jeremy,&lt;/P&gt;&lt;P&gt;Thanks for the reply. Yes I realized after I posted this that it isn't really a Revit API problem.&lt;/P&gt;&lt;P&gt;Because the form and the external event handler are both instantiated in the same external command it was a simple case of adding a reference to the form to my event handler.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sean&lt;/P&gt;</description>
      <pubDate>Sun, 12 Mar 2017 21:11:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/6940733#M59744</guid>
      <dc:creator>sean_dodsworth</dc:creator>
      <dc:date>2017-03-12T21:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: Updating a form from an ExternalEvent handler</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/6940870#M59745</link>
      <description>&lt;P&gt;Sean,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Care to share a small sample of how you did this? I think I am running into the same issue, and this would help.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 00:25:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/6940870#M59745</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-13T00:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Updating a form from an ExternalEvent handler</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/6940975#M59746</link>
      <description>&lt;P&gt;Of course.&lt;/P&gt;&lt;P&gt;The Execute method of my external command looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elemSet)
        {
            var handler = new RequestHandler();
            var exEvent = ExternalEvent.Create(handler);

            // This is the view model that is bound to the WPF window
            var viewModel = new ViewModel(cmdData.Application.ActiveUIDocument);

            // This is the important bit - add a reference to the view model to the reqeust handler
            handler.VM = viewModel;

            // Instantiate the WPF window, pass the external event and handler and also bind to the view model
            var window = new ViewWindow(exEvent, handler) { DataContext = viewModel };
            window.Show();

            return Result.Succeeded;
        }&lt;/PRE&gt;&lt;P&gt;Then in the Execute method of my event handler I call a public method on my view model (which updates the window):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;VM.UpdateSelectedRoom();&lt;/PRE&gt;&lt;P&gt;Its not super elegant but it seems to work ok.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 02:28:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/6940975#M59746</guid>
      <dc:creator>sean_dodsworth</dc:creator>
      <dc:date>2017-03-13T02:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: Updating a form from an ExternalEvent handler</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/6940997#M59747</link>
      <description>&lt;P&gt;Sean,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This makes sense now. Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 02:50:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/6940997#M59747</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-13T02:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Updating a form from an ExternalEvent handler</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/7066155#M59748</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanx I did the same thing with a winform, I added myForm to the ExtEvent handler, so far it has worked well, I can now use multiple buttons and refresh and keep the form alive whilst the user edits the model in between transactions initiated from the external event!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// We give the objects to the new dialog;&lt;BR /&gt;// The dialog becomes the owner responsible for disposing them, eventually.&lt;BR /&gt;m_MyForm = new Fam_DGV_Form(uiapp, exEvent, handler);&lt;BR /&gt;&lt;BR /&gt;//Add the form to the handler, so that the form can be updated from the externalEvent class(the handler)&lt;BR /&gt;handler.FormThing = m_MyForm;&lt;/P&gt;&lt;P&gt;m_MyForm.Show();&lt;/P&gt;</description>
      <pubDate>Sat, 06 May 2017 08:48:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/7066155#M59748</guid>
      <dc:creator>n_mulconray</dc:creator>
      <dc:date>2017-05-06T08:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Updating a form from an ExternalEvent handler</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/8738235#M59749</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am very interested in how the handler references the windows form. Is there anyway I can see the ExternalEventHandler code portion to understand this line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;handler.FormThing = m_MyForm;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am struggling to communicate with an externaleventhandler and a windows form and I believe this is the solution.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Norm&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2019 19:52:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/8738235#M59749</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-04-17T19:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Updating a form from an ExternalEvent handler</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/8739991#M59750</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Dear Norm,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for your query.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yes, the window handle is an important identifier.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For a full-blown IPC sample, you can also take a look at this recent sample:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2019/04/set-floor-level-and-use-ipc-for-disentanglement.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2019/04/set-floor-level-and-use-ipc-for-disentanglement.html&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Though, in general, you should not need that, since your external event handler and Windows form can Norm-ally both easily live together in the same process, in the same add-in, together with Revit itself.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I hope this helps.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 13:17:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/updating-a-form-from-an-externalevent-handler/m-p/8739991#M59750</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-04-18T13:17:55Z</dc:date>
    </item>
  </channel>
</rss>

