<?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: Get UIApplication anywhere. in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/get-uiapplication-anywhere/m-p/13349972#M851</link>
    <description>&lt;P&gt;Thank you for the discovery and sharing! Added to the blog:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2025/03/access-uiapplication-and-bounding-box-on-sheet.html#3" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2025/03/access-uiapplication-and-bounding-box-on-sheet.html#3&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Mar 2025 19:47:00 GMT</pubDate>
    <dc:creator>jeremy_tammik</dc:creator>
    <dc:date>2025-03-03T19:47:00Z</dc:date>
    <item>
      <title>Get UIApplication anywhere.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-uiapplication-anywhere/m-p/13341551#M850</link>
      <description>&lt;P&gt;&lt;STRONG&gt;UIApplication&lt;/STRONG&gt; is the most useful class inside Revit API, give access to all events, documents and can be used to know if your code is in the &lt;STRONG&gt;AddInContext (Revit API Context)&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would be really handy is there a way to have access to &lt;STRONG&gt;UIApplication&lt;/STRONG&gt; any time you need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is a way native way in the &lt;STRONG&gt;RevitAPIUI.dll&lt;/STRONG&gt; to get &lt;STRONG&gt;UIApplication&lt;/STRONG&gt; without any reflection or internal code. I figure out that a long time ago (~3 years) when I was messing with events.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The class &lt;STRONG&gt;RibbonItemEventArgs&lt;/STRONG&gt; have a directly reference for a new &lt;STRONG&gt;UIApplication&lt;/STRONG&gt; class.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;UIApplication uiapp = new Autodesk.Revit.UI.Events.RibbonItemEventArgs().Application;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a class &lt;STRONG&gt;RevitApplication&lt;/STRONG&gt; in my &lt;STRONG&gt;ricaun.Revit.UI&lt;/STRONG&gt; library just to have a base standard.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://github.com/ricaun-io/ricaun.Revit.UI/blob/master/ricaun.Revit.UI/RevitApplication.cs" target="_blank"&gt;https://github.com/ricaun-io/ricaun.Revit.UI/blob/master/ricaun.Revit.UI/RevitApplication.cs&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="csharp"&gt;UIApplication uiapp = RevitApplication.UIApplication;
UIControlledApplication application = RevitApplication.UIControlledApplication;
bool inAddInContext = RevitApplication.IsInAddInContext;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Better when that only if &lt;STRONG&gt;Autodesk&lt;/STRONG&gt; create a static class like &lt;STRONG&gt;RevitApplication&lt;/STRONG&gt; in the &lt;STRONG&gt;RevitAPIUI.dll&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That conclude my post, I hope you like it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See yaa!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 18:08:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-uiapplication-anywhere/m-p/13341551#M850</guid>
      <dc:creator>ricaun</dc:creator>
      <dc:date>2025-02-26T18:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: Get UIApplication anywhere.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-uiapplication-anywhere/m-p/13349972#M851</link>
      <description>&lt;P&gt;Thank you for the discovery and sharing! Added to the blog:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2025/03/access-uiapplication-and-bounding-box-on-sheet.html#3" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2025/03/access-uiapplication-and-bounding-box-on-sheet.html#3&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Mar 2025 19:47:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-uiapplication-anywhere/m-p/13349972#M851</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2025-03-03T19:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Get UIApplication anywhere.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-uiapplication-anywhere/m-p/13370041#M852</link>
      <description>&lt;P&gt;I like to use the Application Idle event to get it and the set a static global from there. I am already doing other things there anyway so might as well!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private void Application_Idling(object sender, IdlingEventArgs args)
    {
        UIApp = sender as UIApplication;
        AppParams.uiApp = UIApp;
        EnableUpdaters(AppParams.application, "all");
        AppParams.application.Idling -= Application_Idling;
    }&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 13 Mar 2025 22:47:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-uiapplication-anywhere/m-p/13370041#M852</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2025-03-13T22:47:11Z</dc:date>
    </item>
  </channel>
</rss>

