<?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: PostCommand &amp;amp; Modal dialog in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/postcommand-amp-modal-dialog/m-p/10227187#M26769</link>
    <description>&lt;P&gt;PostCommand is done after your context has finished. So can't be used for your scenario.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If all you need to do is draw a line or select lines from the same modal dialogue then the easiest way would be to reshow the same dialogue in-between other API methods (not post command) e.g.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UIDocument.Selection.PickPoint x 2 &amp;amp;&amp;nbsp;Document.Create.NewModelCurve&lt;/P&gt;&lt;P&gt;UIDocument.Selection.PickObjects&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Otherwise you need to implement IExternalEventHandler with modeless dialogue.&lt;/P&gt;</description>
    <pubDate>Sat, 10 Apr 2021 11:05:32 GMT</pubDate>
    <dc:creator>RPTHOMAS108</dc:creator>
    <dc:date>2021-04-10T11:05:32Z</dc:date>
    <item>
      <title>PostCommand &amp; Modal dialog</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postcommand-amp-modal-dialog/m-p/10224355#M26767</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use the Revit PostCommand through a button that is in a window (ShowDialog), because I want to keep Revit locked. But the problem is that the PostCommand only launches when my form is closed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had already done this using a While:&lt;BR /&gt;I create the form&lt;BR /&gt;I give him the datacontext&lt;BR /&gt;I am using a CommandToRun property on my ViewModel to determine what to do.&lt;BR /&gt;At the click of a button, I change my CommandToRun property and I close the form.&lt;BR /&gt;And then I determine whether or not to quit the while.&lt;BR /&gt;&lt;BR /&gt;But the problem here is that the postcommand does not launch, because I open a form directly after clicking on the button.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public bool? ShowSeparationByZoneModalForm()
        {
            bool? res = null;
            Boolean reallyExit = false;
            while (!reallyExit)
            {
                // form.PopulateFormData();
                if (viewModel.CommandToRun == RunCommand.None)
                {
                    SeparationByZoneDialog form = new SeparationByZoneDialog();
                    form.Helper().Owner = RevitWindowHelper.GetRevitHandle();
                    form.DataContext = viewModel;
                    res = form.ShowDialog();
                    switch (viewModel.CommandToRun)
                    {
                        case RunCommand.DrawLines:
                            {
                                App.DocumentChanged += OnDocumentChanged;
                                UIApp.Idling += OnIdling;
                                RevitCommandId modelLineCmd = RevitCommandId.LookupPostableCommandId(PostableCommand.ModelLine);
                                UIApp.PostCommand(modelLineCmd);
                            }
                            break;
                        case RunCommand.SelectLines:
                            {
                                viewModel.CommandToRun = RunCommand.None;
                                var uidoc = new UIDocument(_doc);
                                Selection choices = uidoc.Selection;
                                try
                                {
                                    Reference hasPickOne = choices.PickObject(ObjectType.Element);
                                    if (hasPickOne != null)
                                        viewModel.LineCounter += 1;
                                }
                                catch (Autodesk.Revit.Exceptions.OperationCanceledException oce)
                                { }
                            }
                            break;
                        case RunCommand.None:
                            reallyExit = true;
                            break;
                        default:
                            reallyExit = true;
                            break;
                    }
                }
            }
            return res;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This method works great for making element selections in Revit keeping the window blocking but with postcommands it doesn't work.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 08:59:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postcommand-amp-modal-dialog/m-p/10224355#M26767</guid>
      <dc:creator>minet.axel</dc:creator>
      <dc:date>2021-04-09T08:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: PostCommand &amp; Modal dialog</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postcommand-amp-modal-dialog/m-p/10224543#M26768</link>
      <description>&lt;P&gt;I'm not good at English! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You can refer to using template to work with revit api.&lt;/P&gt;&lt;P&gt;Link :&amp;nbsp;&lt;A href="https://github.com/imAliAsad/VisualStudioRevitTemplate" target="_blank"&gt;https://github.com/imAliAsad/VisualStudioRevitTemplate&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hope to help you!!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 10:39:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postcommand-amp-modal-dialog/m-p/10224543#M26768</guid>
      <dc:creator>dreamofbaby0507</dc:creator>
      <dc:date>2021-04-09T10:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: PostCommand &amp; Modal dialog</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postcommand-amp-modal-dialog/m-p/10227187#M26769</link>
      <description>&lt;P&gt;PostCommand is done after your context has finished. So can't be used for your scenario.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If all you need to do is draw a line or select lines from the same modal dialogue then the easiest way would be to reshow the same dialogue in-between other API methods (not post command) e.g.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UIDocument.Selection.PickPoint x 2 &amp;amp;&amp;nbsp;Document.Create.NewModelCurve&lt;/P&gt;&lt;P&gt;UIDocument.Selection.PickObjects&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Otherwise you need to implement IExternalEventHandler with modeless dialogue.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Apr 2021 11:05:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postcommand-amp-modal-dialog/m-p/10227187#M26769</guid>
      <dc:creator>RPTHOMAS108</dc:creator>
      <dc:date>2021-04-10T11:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: PostCommand &amp; Modal dialog</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postcommand-amp-modal-dialog/m-p/10228874#M26770</link>
      <description>&lt;P&gt;I want to use a post command. so i modified my form to use an IExternalEventHandler. thank you for the information.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Apr 2021 11:53:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postcommand-amp-modal-dialog/m-p/10228874#M26770</guid>
      <dc:creator>minet.axel</dc:creator>
      <dc:date>2021-04-11T11:53:56Z</dc:date>
    </item>
  </channel>
</rss>

