<?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: Changes cannot be shown until the external command ends in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4319296#M79216</link>
    <description>Hi Marc,&lt;BR /&gt;&lt;BR /&gt;Would you try start transaction in the button handler, and commit it within the button handler too?  You need to pass in the current document to ProjectSetupForm class. So transaction can be started within class ProjectSetupForm.&lt;BR /&gt;&lt;BR /&gt;Hope this helps.</description>
    <pubDate>Thu, 04 Jul 2013 06:21:23 GMT</pubDate>
    <dc:creator>Joe.Ye</dc:creator>
    <dc:date>2013-07-04T06:21:23Z</dc:date>
    <item>
      <title>Changes cannot be shown until the external command ends</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4310848#M79209</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have a command that is triggered by button in a ribbon. This command creates multiple ViewPlans automatically, the issue that I'm facing is that when I run the command the form shows fine I create the new Views but the changes are not shown until I close the form and the external command ends.&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;How can I do the same task but being able to see the changes instantly in the background without having to close the form? &amp;nbsp;I have seen that in other addins but I don't know what I'm doing different.&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;Here is some of my code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;    [Transaction(TransactionMode.Automatic)]    
    public class Command : IExternalCommand
    {
        Result IExternalCommand.Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements) 
        {
            ViewCreator myViews = new ViewCreator(commandData);            

            try
            {
                ProjectSetupForm myForm = new ProjectSetupForm(myViews);
                myForm.ShowDialog();
                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return Result.Failed;
            }
        }  
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ViewCreator is my class where I have all my properties and methods.&lt;/P&gt;&lt;P&gt;I create all de ViewPlans inside the form with all the data that the user inputs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really apreciate your help.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Marc&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2013 21:55:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4310848#M79209</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-06-26T21:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: Changes cannot be shown until the external command ends</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4311044#M79210</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Document.Regenerate() function usually does what you are looking for.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2013 05:37:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4311044#M79210</guid>
      <dc:creator>ollikat</dc:creator>
      <dc:date>2013-06-27T05:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Changes cannot be shown until the external command ends</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4311471#M79211</link>
      <description>&lt;P&gt;Thanks for your help ollikat I really appreciate it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to use the&amp;nbsp;Document.Regenerate() method but it doesn't seams to work for my program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you think that it has something to do with opening the form in modal?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I try to show the form modless like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;myForm.Show();&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The program crashes in this line of code when I use ViewPlan.Create method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ViewPlan vPlan = ViewPlan.Create(_doc, vft.Id, levelID);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2013 13:27:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4311471#M79211</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-06-27T13:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Changes cannot be shown until the external command ends</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4312246#M79212</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry to hear that Regenerate doesn't help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No I don't think that modal dialog has any effect on your issue...at least directly. You might be able to do some magic with modeless dialog and idling event etc. but tha's not my strongest area currently.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as I know, only option you have left is that you commit the transaction where you have created those objects. It should refresh the project up to date.&lt;BR /&gt;&lt;BR /&gt;Although I have to admit that I'm not perfectly aware how those view plans should appear. Someone else in this forum was askin whether changing the selection trough API would cause property palette to update, but that wasn't possible while external command was executing. So maybe there's something similar here (?).&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2013 06:37:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4312246#M79212</guid>
      <dc:creator>ollikat</dc:creator>
      <dc:date>2013-06-28T06:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: Changes cannot be shown until the external command ends</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4312710#M79213</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for your help! I'll try to play with it and see how it goes. No luck so far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I find a way to fix it I'll reply back the solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2013 13:58:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4312710#M79213</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-06-28T13:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Changes cannot be shown until the external command ends</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4316366#M79214</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because you are using the automatic transaction model. So the model will not get updated until the command end and the automatica transaction commited.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The solution is to use the manual external transaction mode. And start the transaction before changing the model. Then just afte the change, Commit the transaction immediately in the handler of the button.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should be able to update the model when the form is visible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;______________________________________________________________&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0174DF"&gt;If my post answers your question, please click the &lt;STRONG&gt;"Accept as Solution"&lt;/STRONG&gt; button. This helps everyone find answers more quickly!&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2013 09:49:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4316366#M79214</guid>
      <dc:creator>Joe.Ye</dc:creator>
      <dc:date>2013-07-02T09:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Changes cannot be shown until the external command ends</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4317336#M79215</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help. I can't get the model update until the command ends. This is what I've changed so far, but is not updating the model because all changes are happening inside the form.&lt;/P&gt;&lt;P&gt;How can I make sure that I commit those changes multiple times inside the form?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
    public class Command : IExternalCommand
    {
        Result IExternalCommand.Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements) 
        {
            Document _doc = commandData.Application.ActiveUIDocument.Document;

            ViewCreator myViews = new ViewCreator(commandData);            

            try
            {
                using (Transaction trans = new Transaction(_doc,"CreateViews"))
                {
                    trans.Start();

                    ProjectSetupForm myForm = new ProjectSetupForm(myViews);
                    myForm.ShowDialog();

                    trans.Commit();
                }
                
                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return Result.Failed;
            }
        }  &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for any help provided!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Marc&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2013 22:04:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4317336#M79215</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-07-02T22:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Changes cannot be shown until the external command ends</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4319296#M79216</link>
      <description>Hi Marc,&lt;BR /&gt;&lt;BR /&gt;Would you try start transaction in the button handler, and commit it within the button handler too?  You need to pass in the current document to ProjectSetupForm class. So transaction can be started within class ProjectSetupForm.&lt;BR /&gt;&lt;BR /&gt;Hope this helps.</description>
      <pubDate>Thu, 04 Jul 2013 06:21:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4319296#M79216</guid>
      <dc:creator>Joe.Ye</dc:creator>
      <dc:date>2013-07-04T06:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Changes cannot be shown until the external command ends</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4324292#M79217</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again! This time worked perfectly! For some reason I thought that I had to do the transaction within the Command class.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed the transaction to Manual&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
    public class Command : IExternalCommand
    {
        Result IExternalCommand.Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            ViewCreator myViews = new ViewCreator(commandData);          

            try
            {
                ProjectSetupForm myForm = new ProjectSetupForm(myViews);
                myForm.ShowDialog();
                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return Result.Failed;
            }
        }
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then inside my ViewCreator class I did the transaction with the method that creates every view.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;using (Transaction trans = new Transaction(_doc, "CreateViews"))
{
    trans.Start();

    // Code ...

    trans.Commit();
} &lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for your help!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Marc&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2013 16:16:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/changes-cannot-be-shown-until-the-external-command-ends/m-p/4324292#M79217</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-07-09T16:16:18Z</dc:date>
    </item>
  </channel>
</rss>

