<?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: Close Active Project/Document using UIFramework in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/close-active-project-document-using-uiframework/m-p/13607515#M862</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3485440"&gt;@rhanzlick&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Is there a reason you would want to close a UIDocument vs the UIDocument.Document? What’s the nuance/usecase for the former? (Just out of curiosity.)&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;Is not possible to close the active document, the &lt;STRONG&gt;Remarks&lt;/STRONG&gt; in the documentation for the &lt;STRONG&gt;Close&lt;/STRONG&gt; method mention that.&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;EM&gt;"The currently active document may not be closed by this function. It can only be closed via Revit's UI."&lt;/EM&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if you use &lt;STRONG&gt;OpenAndActivateDocument&lt;/STRONG&gt; and need to close the active document the &lt;STRONG&gt;Close&lt;/STRONG&gt; method does not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;UIDocument uidoc = uiapp.OpenAndActivateDocument("Sample.rvt");
uidoc.Document.Close(false); // Fail to close.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the extension should work to close the active document using the Revit UI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;UIDocument uidoc = uiapp.OpenAndActivateDocument("Sample.rvt");
uiapp.CloseActiveUIDocument();&lt;/LI-CODE&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>Wed, 30 Apr 2025 12:23:24 GMT</pubDate>
    <dc:creator>ricaun</dc:creator>
    <dc:date>2025-04-30T12:23:24Z</dc:date>
    <item>
      <title>Close Active Project/Document using UIFramework</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/close-active-project-document-using-uiframework/m-p/13338401#M859</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some reason Revit API does not allow to close an&amp;nbsp;&lt;STRONG&gt;ActiveUIDocument&lt;/STRONG&gt;, and I know is possible to close using press &lt;A href="https://thebuildingcoder.typepad.com/blog/2010/10/closing-the-active-document-and-why-not-to.html" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;F4&lt;/STRONG&gt;&lt;/A&gt; or &lt;A href="https://thebuildingcoder.typepad.com/blog/2019/04/close-doc-and-zero-doc-rvtsamples.html#5" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;PostCommand.Close&lt;/STRONG&gt;&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to share a different approach using &lt;STRONG&gt;UIFramework &lt;/STRONG&gt;reference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the extension for the &lt;STRONG&gt;UIApplication&lt;/STRONG&gt; to enable &lt;STRONG&gt;&lt;SPAN class=""&gt;CloseAllUIDocument&lt;/SPAN&gt; &lt;/STRONG&gt;and &lt;STRONG&gt;&lt;SPAN class=""&gt;CloseActiveUIDocument&lt;/SPAN&gt;&lt;/STRONG&gt;.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://gist.github.com/ricaun/ff6814faf407ee044b93ee8e787f628c" target="_blank" rel="noopener"&gt;https://gist.github.com/ricaun/ff6814faf407ee044b93ee8e787f628c&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically the code close UI document window and use the event &lt;STRONG&gt;&lt;SPAN class=""&gt;DialogBoxShowing&lt;/SPAN&gt; &lt;/STRONG&gt;to force to save or not the document if the save popup happens.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a simple Command to close the &lt;STRONG&gt;&lt;SPAN class=""&gt;ActiveUIDocument&lt;/SPAN&gt;&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;[Transaction(TransactionMode.Manual)]
public class CommandCloseActiveUIDocument : IExternalCommand
{
    public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
    {
        UIApplication uiapp = commandData.Application;

        uiapp.CloseActiveUIDocument();

        return Result.Succeeded;
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To use the extension your project need to have the &lt;STRONG&gt;UIFramework&amp;nbsp;&lt;/STRONG&gt;reference, you can add the reference using the packages below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;PackageReference Include="Revit_All_Main_Versions_API_x64" Version="$(RevitVersion).*" IncludeAssets="build; compile" PrivateAssets="All" /&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;PackageReference Include="Nice3point.Revit.Api.UIFramework" Version="$(RevitVersion).*"/&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See yaa!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 12:50:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/close-active-project-document-using-uiframework/m-p/13338401#M859</guid>
      <dc:creator>ricaun</dc:creator>
      <dc:date>2025-02-25T12:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Close Active Project/Document using UIFramework</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/close-active-project-document-using-uiframework/m-p/13338722#M860</link>
      <description>&lt;P&gt;This should definitely be in the default API, why such restrictions&lt;span class="lia-unicode-emoji" title=":see_no_evil_monkey:"&gt;🙈&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 14:31:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/close-active-project-document-using-uiframework/m-p/13338722#M860</guid>
      <dc:creator>nice3point</dc:creator>
      <dc:date>2025-02-25T14:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: Close Active Project/Document using UIFramework</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/close-active-project-document-using-uiframework/m-p/13606654#M861</link>
      <description>&lt;P&gt;Is there a reason you would want to close a UIDocument vs the UIDocument.Document? What’s the nuance/usecase for the former? (Just out of curiosity.)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2025 23:57:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/close-active-project-document-using-uiframework/m-p/13606654#M861</guid>
      <dc:creator>rhanzlick</dc:creator>
      <dc:date>2025-04-29T23:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Close Active Project/Document using UIFramework</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/close-active-project-document-using-uiframework/m-p/13607515#M862</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3485440"&gt;@rhanzlick&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Is there a reason you would want to close a UIDocument vs the UIDocument.Document? What’s the nuance/usecase for the former? (Just out of curiosity.)&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;Is not possible to close the active document, the &lt;STRONG&gt;Remarks&lt;/STRONG&gt; in the documentation for the &lt;STRONG&gt;Close&lt;/STRONG&gt; method mention that.&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;EM&gt;"The currently active document may not be closed by this function. It can only be closed via Revit's UI."&lt;/EM&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if you use &lt;STRONG&gt;OpenAndActivateDocument&lt;/STRONG&gt; and need to close the active document the &lt;STRONG&gt;Close&lt;/STRONG&gt; method does not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;UIDocument uidoc = uiapp.OpenAndActivateDocument("Sample.rvt");
uidoc.Document.Close(false); // Fail to close.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the extension should work to close the active document using the Revit UI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;UIDocument uidoc = uiapp.OpenAndActivateDocument("Sample.rvt");
uiapp.CloseActiveUIDocument();&lt;/LI-CODE&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>Wed, 30 Apr 2025 12:23:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/close-active-project-document-using-uiframework/m-p/13607515#M862</guid>
      <dc:creator>ricaun</dc:creator>
      <dc:date>2025-04-30T12:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: Close Active Project/Document using UIFramework</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/close-active-project-document-using-uiframework/m-p/14113981#M85583</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4176855"&gt;@ricaun&lt;/a&gt;&amp;nbsp; Somehow I tested willy nilly and got this working with your extension methods, although I'm passing commandlinks instead of yes/no in the OnDialogBoxShowing handler. So it can be applied to any dialog right? (&lt;A href="https://rvtdocs.com/2025/bde54cc2-a445-8610-0ced-1851f04eea18" target="_blank"&gt;https://rvtdocs.com/2025/bde54cc2-a445-8610-0ced-1851f04eea18&lt;/A&gt;)&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2026 22:21:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/close-active-project-document-using-uiframework/m-p/14113981#M85583</guid>
      <dc:creator>K.Calero_Arup</dc:creator>
      <dc:date>2026-05-01T22:21:30Z</dc:date>
    </item>
  </channel>
</rss>

