<?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: modeless dialogue and external events with trasaction in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9420359#M35483</link>
    <description>&lt;P&gt;Hey, that sounds interesting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Am I right in assuming that you wish to change various different things in your modeless dialogue and see the intermediate results before confirming the commit?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That might require regeneration of the model, and even committing the transaction.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you wish to pan and zoom before committing the transaction?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This may be difficult or impossible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The external event handler implements an execute method. In that method, you can open a transaction, close and commit it. You can do the same with a transaction group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I hardly believe that you can open a transaction or transaction group and leave it open after returning from the event handler. and then returning to a different event handler by raising separate subsequent external event to close it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tricky and interesting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please clarify further what you are after.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please take time and care to formulate your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are in a hurry, do something else by yourself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please do not ask questions to other people in a hurry, or you will be wasting everybodys time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Apr 2020 14:39:03 GMT</pubDate>
    <dc:creator>jeremytammik</dc:creator>
    <dc:date>2020-04-03T14:39:03Z</dc:date>
    <item>
      <title>Modelles form and external event with trasaction</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9417203#M35480</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Is it possible with modelles form and external events command with Trasaction group??&lt;/P&gt;&lt;P&gt;Open trasaction group when modelles is show. Then make some other modification in model with several buttons and then close form with transaction group close..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thx.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 11:16:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9417203#M35480</guid>
      <dc:creator>sonicer</dc:creator>
      <dc:date>2020-04-02T11:16:48Z</dc:date>
    </item>
    <item>
      <title>Re: Modelles form and external event with trasaction</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9418015#M35481</link>
      <description>&lt;P&gt;You should really use a spell checker, especially in the description of your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The spelling errors you introduce make it harder to understand your question and almost impossible to find it again in subsequent searches.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I spell check almost everything I publish as a courtesy to my fellow human beings and also to the inhuman search engines, even though the latter can cope better with typos.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, to address your question:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use a transaction group exactly and absolutely everywhere that a normal transaction can be used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In other words, it requires a valid Revit API context, nothing more and nothing less.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is more information about thew&amp;nbsp;valid Revit API context:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.28" target="_blank" rel="noopener"&gt;https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.28&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is everything you need to know about transaction groups:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.53" target="_blank" rel="noopener"&gt;https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.53&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 16:16:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9418015#M35481</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2020-04-02T16:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: modeless dialogue and external events with trasaction</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9419797#M35482</link>
      <description>&lt;P&gt;I'm sorry, I wrote it in a hurry.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I am preparing some add-in for Revit.&lt;/P&gt;&lt;P&gt;I have modeless dialogue with many buttons.&lt;/P&gt;&lt;P&gt;The buttons call external events with transaction.&lt;/P&gt;&lt;P&gt;Is it possible all this transaction assimilate after closing this dialogue?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Why I am using modeless dialogue?&lt;BR /&gt;I need to be able use pan/zoom function on the floor plan to see the preview result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thx.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 10:17:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9419797#M35482</guid>
      <dc:creator>sonicer</dc:creator>
      <dc:date>2020-04-03T10:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: modeless dialogue and external events with trasaction</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9420359#M35483</link>
      <description>&lt;P&gt;Hey, that sounds interesting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Am I right in assuming that you wish to change various different things in your modeless dialogue and see the intermediate results before confirming the commit?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That might require regeneration of the model, and even committing the transaction.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you wish to pan and zoom before committing the transaction?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This may be difficult or impossible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The external event handler implements an execute method. In that method, you can open a transaction, close and commit it. You can do the same with a transaction group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I hardly believe that you can open a transaction or transaction group and leave it open after returning from the event handler. and then returning to a different event handler by raising separate subsequent external event to close it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tricky and interesting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please clarify further what you are after.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please take time and care to formulate your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are in a hurry, do something else by yourself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please do not ask questions to other people in a hurry, or you will be wasting everybodys time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 14:39:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9420359#M35483</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2020-04-03T14:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: modeless dialogue and external events with trasaction</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9420402#M35484</link>
      <description>&lt;P&gt;One possible solution:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public class MyWindow : Window, IExternalEventHandler
{
  private IList&amp;lt;Action&amp;lt;UIApplication&amp;gt;&amp;gt; _actions;
  private IList&amp;lt;Action&amp;lt;UIApplication&amp;gt;&amp;gt; Actions =&amp;gt; _actions ?? (_actions = new List&amp;lt;Action&amp;lt;UIApplication&amp;gt;&amp;gt;());

  public MyWindow()
  {
    var commit = ExternalEvent.Create(this);
    this.Closed += (sender,e) =&amp;gt; {
      commit.Raise();
    }
  }
  
  public void Execute(UIApplication application)
  {
    using (var transaction = new Transaction(application.ActionUIDocument.Document,"doing something"))
    {
        transaction.Start();
        Actions.ForEach(action =&amp;gt; {
          action(app);
        })
        transaction.Commit();
    }
  }

  private void OnOneButtonClick(object sender, EventArgs e)
  {
    Actions.Add(app =&amp;gt; 
    {
      // some business code here
    })
  }

  private void OnAnotherButtonClick(object sender, EventArgs e)
  {
    Actions.Add(app =&amp;gt; 
    {
      // some business code here
    })
  }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 03 Apr 2020 14:54:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9420402#M35484</guid>
      <dc:creator>Kennan.Chen</dc:creator>
      <dc:date>2020-04-03T14:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: modeless dialogue and external events with trasaction</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9420417#M35485</link>
      <description>&lt;P&gt;Sorry for my carelessness.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code should be :&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Actions.ForEach(action =&amp;gt; {
  action(application);
})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 14:59:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9420417#M35485</guid>
      <dc:creator>Kennan.Chen</dc:creator>
      <dc:date>2020-04-03T14:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: Modelles form and external event with trasaction</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9420433#M35486</link>
      <description>&lt;P&gt;My carelessness again. The window will be disposed on closed so the IExternalEventHandler instance will not be available if the window itself implements IExternalEventHandler. We'd better separate them.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public class MyWindow : Window
{
  private AccumulatedExternalEventHandler EventHandler { get; }
  public MyWindow()
  {
    EventHandler = new AccumulatedExternalEventHandler();
    var commit = ExternalEvent.Create(EventHandler);
    this.Closed += (sender,e) =&amp;gt; {
      commit.Raise();
    };
  }

  private void OnOneButtonClick(object sender, EventArgs e)
  {
    EventHandler.Add(app =&amp;gt;
    {
      // revit api code here
    });
  }

  private void OnAnotherButtonClick(object sender, EventArgs e)
  {
    EventHandler.Add(app =&amp;gt;
    {
      // revit api code here
    });
  }
}

public class AccumulatedExternalEventHandler : IExternalEventHandler
{
  private IList&amp;lt;Action&amp;lt;UIApplication&amp;gt;&amp;gt; _actions;
  private IList&amp;lt;Action&amp;lt;UIApplication&amp;gt;&amp;gt; Actions =&amp;gt; _actions ?? (_actions = new List&amp;lt;Action&amp;lt;UIApplication&amp;gt;&amp;gt;());

  public void Add(Action&amp;lt;UIApplication&amp;gt; action)
  {
    Actions.Add(action);
  }

  public void Execute(UIApplication application)
  {
    using (var transaction = new Transaction(application.ActionUIDocument.Document,"doing something"))
    {
        transaction.Start();
        Actions.ForEach(action =&amp;gt; {
          action(application);
        })
        transaction.Commit();
    }
  }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 03 Apr 2020 15:07:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9420433#M35486</guid>
      <dc:creator>Kennan.Chen</dc:creator>
      <dc:date>2020-04-03T15:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Modelles form and external event with trasaction</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9427187#M35487</link>
      <description>&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;thats look like very interesting.&lt;/P&gt;&lt;P&gt;I found some blog about external events and trasaction group.&lt;/P&gt;&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2018/11/more-on-transaction-groups-and-assimilation.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2018/11/more-on-transaction-groups-and-assimilation.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I change my concept from modelles dialog to modal dialog and used for preview&amp;nbsp; PreviewControl from Revit api.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thx all.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 12:37:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/modelles-form-and-external-event-with-trasaction/m-p/9427187#M35487</guid>
      <dc:creator>sonicer</dc:creator>
      <dc:date>2020-04-07T12:37:15Z</dc:date>
    </item>
  </channel>
</rss>

