<?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: Automatically OpenAndActivate a cloud model on Revit startup in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/automatically-openandactivate-a-cloud-model-on-revit-startup/m-p/13296069#M1181</link>
    <description>&lt;P&gt;OnStartup is useful to register event handlers and set up add-ins and stuff, but it is not the optimal time and place to start executing code. ApplicationInitialized is a later and probably more suitable choice:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://www.revitapidocs.com/2024/f35ba9fc-0b6b-4284-60eb-91788761127c.htm" target="_blank"&gt;https://www.revitapidocs.com/2024/f35ba9fc-0b6b-4284-60eb-91788761127c.htm&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Subscribe to this event to get notified after the Revit application has been initialized.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Feb 2025 05:34:48 GMT</pubDate>
    <dc:creator>jeremy_tammik</dc:creator>
    <dc:date>2025-02-03T05:34:48Z</dc:date>
    <item>
      <title>Automatically OpenAndActivate a cloud model on Revit startup</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/automatically-openandactivate-a-cloud-model-on-revit-startup/m-p/13295289#M1178</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to automatically OpenAndActivate a cloud model. Given I need to access&amp;nbsp;UIApplication I am doing it via&amp;nbsp;UIControlledApplication.Idling event.&lt;/P&gt;&lt;P&gt;The command works fine when I open a local Revit model. However when I open a cloud model I am left with the following dialog 'Open Model' indefinitely and I have no option but to kill the Revit session.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rockit_for_Revit_0-1738498888645.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1461847i8EBA5A1E36A49BAE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rockit_for_Revit_0-1738498888645.png" alt="Rockit_for_Revit_0-1738498888645.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I am opening the cloud model using the following:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim modelPath As ModelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath(If(region, ModelPathUtils.CloudRegionUS), ' Default to US region if not provided
    New Guid(projectGUID),
    New Guid(modelGUID)
)
Dim openOptions As New OpenOptions()
Dim objUIdocument As UIDocument = uiApp.OpenAndActivateDocument(modelPath, openOptions, False)&lt;/LI-CODE&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2025 12:29:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/automatically-openandactivate-a-cloud-model-on-revit-startup/m-p/13295289#M1178</guid>
      <dc:creator>Rockit_for_Revit</dc:creator>
      <dc:date>2025-02-02T12:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically OpenAndActivate a cloud model on Revit startup</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/automatically-openandactivate-a-cloud-model-on-revit-startup/m-p/13295457#M1179</link>
      <description>&lt;P&gt;Maybe it's &lt;STRONG&gt;Idling&lt;/STRONG&gt;, it's usually not safe to run long processes in there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could use &lt;STRONG&gt;ExternalEvent&lt;/STRONG&gt; and verify if that works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some sample code like this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System;

namespace RevitAddin.Forum
{
    public class AppCloud : IExternalApplication
    {
        public Result OnStartup(UIControlledApplication application)
        {
            var region = ModelPathUtils.CloudRegionUS;
            var projectGuid = Guid.Parse("00000000-0000-0000-0000-000000000000");
            var modelGuid = Guid.Parse("00000000-0000-0000-0000-000000000000");

            // Create ExternalEvent and Raise to execute in the next idle cycle
            ExternalEvent.Create(new CloudOpenExternalEvent(region, projectGuid, modelGuid)).Raise();
            return Result.Succeeded;
        }

        public Result OnShutdown(UIControlledApplication application)
        {
            return Result.Succeeded;
        }
    }

    public class CloudOpenExternalEvent : IExternalEventHandler
    {
        private string Region;
        private Guid ProjectGuid;
        private Guid ModelGuid;

        public CloudOpenExternalEvent(string region, Guid projectGuid, Guid modelGuid)
        {
            Region = region;
            ProjectGuid = projectGuid;
            ModelGuid = modelGuid;
        }
        public void Execute(UIApplication uiapp)
        {
            try
            {
                var modelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath(Region, ProjectGuid, ModelGuid);
                var options = new OpenOptions();
                uiapp.OpenAndActivateDocument(modelPath, options, false);
            }
            catch (Exception ex)
            {
                TaskDialog.Show(GetName(), ex.ToString());
            }
        }
        public string GetName()
        {
            return nameof(CloudOpenExternalEvent);
        }
    }
}&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2025 16:38:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/automatically-openandactivate-a-cloud-model-on-revit-startup/m-p/13295457#M1179</guid>
      <dc:creator>ricaun</dc:creator>
      <dc:date>2025-02-02T16:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically OpenAndActivate a cloud model on Revit startup</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/automatically-openandactivate-a-cloud-model-on-revit-startup/m-p/13296008#M1180</link>
      <description>&lt;P&gt;Perfect thank you so much. I needed to seperate it out of OnStartup, however its essentally the same:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;    Private Shared _externalEvent As ExternalEvent

    Public Sub CreateAndRaiseExternalEvent(filePath As String)
        _externalEvent = ExternalEvent.Create(New ExternalEvent(filePath))
        _externalEvent.Raise()
    End Sub&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 03 Feb 2025 04:06:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/automatically-openandactivate-a-cloud-model-on-revit-startup/m-p/13296008#M1180</guid>
      <dc:creator>Rockit_for_Revit</dc:creator>
      <dc:date>2025-02-03T04:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically OpenAndActivate a cloud model on Revit startup</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/automatically-openandactivate-a-cloud-model-on-revit-startup/m-p/13296069#M1181</link>
      <description>&lt;P&gt;OnStartup is useful to register event handlers and set up add-ins and stuff, but it is not the optimal time and place to start executing code. ApplicationInitialized is a later and probably more suitable choice:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://www.revitapidocs.com/2024/f35ba9fc-0b6b-4284-60eb-91788761127c.htm" target="_blank"&gt;https://www.revitapidocs.com/2024/f35ba9fc-0b6b-4284-60eb-91788761127c.htm&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Subscribe to this event to get notified after the Revit application has been initialized.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 05:34:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/automatically-openandactivate-a-cloud-model-on-revit-startup/m-p/13296069#M1181</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2025-02-03T05:34:48Z</dc:date>
    </item>
  </channel>
</rss>

