<?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 Revit connected and disconnected continuity nodejs server. in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/revit-connected-and-disconnected-continuity-nodejs-server/m-p/9745259#M31864</link>
    <description>&lt;P&gt;&amp;nbsp;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;Hi Mr.Jeremy Tammik,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to connect revit to server nodejs localhost&amp;nbsp;follow the directions of Mr.Jeremy Tammik (roomedit3d).&lt;BR /&gt;When i test by Program.cs . Everything seem fine.&lt;/P&gt;&lt;P&gt;But when i test code to Revit listen event from server isn't fine.&amp;nbsp;Nothing happened in Revit&lt;BR /&gt;I don't know why.&lt;BR /&gt;Please help me if you can.&lt;BR /&gt;Many thanks.&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/818862i732590FA3C4C69D6/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/818868i9CFCAB9C72248D80/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.png" alt="2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;#region Namespaces
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Newtonsoft.Json.Linq;
using Quobject.SocketIoClientDotNet.Client;
#endregion

namespace Roomedit3dApp
{
  class App : IExternalApplication
  {
    /// &amp;lt;summary&amp;gt;
    /// Caption
    /// &amp;lt;/summary&amp;gt;
    public const string Caption = "Roomedit3d";

    /// &amp;lt;summary&amp;gt;
    /// Socket broadcast URL.
    /// &amp;lt;/summary&amp;gt;
    const string _url = "http://localhost:3000";

    #region External event subscription and handling
    /// &amp;lt;summary&amp;gt;
    /// Store the external event.
    /// &amp;lt;/summary&amp;gt;
    static ExternalEvent _event = null;

    /// &amp;lt;summary&amp;gt;
    /// Store the external event.
    /// &amp;lt;/summary&amp;gt;
    //static BimUpdater _bimUpdater = null;

    static VisibleData _visibleData = null;
    /// &amp;lt;summary&amp;gt;
    /// Store the socket we are listening to.
    /// &amp;lt;/summary&amp;gt;
    static Socket _socket = null;

    /// &amp;lt;summary&amp;gt;
    /// Enqueue a new BIM updater task.
    /// &amp;lt;/summary&amp;gt;
    
    public static void VisibleData(object data)
    {
    JObject data2 = JObject.FromObject(data);
    _visibleData.Enqueue(data2.ToString());
    TaskDialog.Show("abc", data2.ToString());
    _event.Raise();
    }

    /// &amp;lt;summary&amp;gt;
    /// Toggle on and off subscription to automatic 
    /// BIM update from cloud. Return true when subscribed.
    /// &amp;lt;/summary&amp;gt;
    public static bool ToggleSubscription()
    {
      
      if ( null != _event )
      {
        Util.Log( "Unsubscribing..." );

        _socket.Disconnect();
        _socket = null;

        //_bimUpdater = null;
        _visibleData = null;
        _event.Dispose();
        _event = null;

        Util.Log( "Unsubscribed." );
        //Util.Log("Goodbye Tester !");
      }
      else
      {
        Util.Log( "Subscribing..." );

        //_bimUpdater = new BimUpdater();
        _visibleData = new VisibleData();
        var options = new IO.Options()
        {
          IgnoreServerCertificateValidation = true,
          AutoConnect = true,
          ForceNew = true
        };

        _socket = IO.Socket( _url, options );

        _socket.On( Socket.EVENT_CONNECT, () 
          =&amp;gt; Util.Log( "Connected" ) );

        //_socket.On( "transform", data 
        //  =&amp;gt; Enqueue( data ) );
        _socket.On("send-data-from-server", data
            =&amp;gt; VisibleData(data));

        //_event = ExternalEvent.Create( _bimUpdater );
        _event = ExternalEvent.Create(_visibleData);
        Util.Log( "Subscribed." );
        //Util.Log("Hello Tester !");
      }
      //return false;
      return null != _event;
    }
    #endregion // External event subscription and handling

    public Result OnStartup( UIControlledApplication a )
    {

      return Result.Succeeded;
    }

    public Result OnShutdown( UIControlledApplication a )
    {
      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;&amp;nbsp;Here is IExternalEventHandler:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;#region Namespaces
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Events;

#endregion

namespace Roomedit3dApp
{
  /// &amp;lt;summary&amp;gt;
  /// BIM updater, driven both via external 
  /// command and external event handler.
  /// &amp;lt;/summary&amp;gt;
  class VisibleData : IExternalEventHandler
  {
    /// &amp;lt;summary&amp;gt;
    /// The queue of pending tasks consisting 
    /// of UniqueID and translation offset vector.
    /// &amp;lt;/summary&amp;gt;
    Queue&amp;lt;string&amp;gt; _queue = null;

    
    public VisibleData()
    {
      _queue = new Queue&amp;lt;string&amp;gt;();
    }

    /// &amp;lt;summary&amp;gt;
    /// Execute method invoked by Revit via the 
    /// external event as a reaction to a call 
    /// to its Raise method.
    /// &amp;lt;/summary&amp;gt;
   

    public void Execute(UIApplication a)
    {
        Document doc = a.ActiveUIDocument.Document;
        using (Transaction t = new Transaction(doc))
        {
            t.Start("Visible data");

            TaskDialog.Show("Test", _queue.Dequeue());
            t.Commit();
        }
    }
    /// &amp;lt;summary&amp;gt;
    /// Required IExternalEventHandler interface 
    /// method returning a descriptive name.
    /// &amp;lt;/summary&amp;gt;
    public string GetName()
    {
      return App.Caption + " " + GetType().Name;
    }

    /// &amp;lt;summary&amp;gt;
    /// Enqueue a BIM update action to be performed,
    /// consisting of UniqueID and translation 
    /// offset vector.
    /// &amp;lt;/summary&amp;gt;
    public void Enqueue( string uid)
    {
      _queue.Enqueue(uid);
    }
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Sep 2020 08:35:45 GMT</pubDate>
    <dc:creator>mr.engineer.aec</dc:creator>
    <dc:date>2020-09-14T08:35:45Z</dc:date>
    <item>
      <title>Revit connected and disconnected continuity nodejs server.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-connected-and-disconnected-continuity-nodejs-server/m-p/9745259#M31864</link>
      <description>&lt;P&gt;&amp;nbsp;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;Hi Mr.Jeremy Tammik,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to connect revit to server nodejs localhost&amp;nbsp;follow the directions of Mr.Jeremy Tammik (roomedit3d).&lt;BR /&gt;When i test by Program.cs . Everything seem fine.&lt;/P&gt;&lt;P&gt;But when i test code to Revit listen event from server isn't fine.&amp;nbsp;Nothing happened in Revit&lt;BR /&gt;I don't know why.&lt;BR /&gt;Please help me if you can.&lt;BR /&gt;Many thanks.&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/818862i732590FA3C4C69D6/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/818868i9CFCAB9C72248D80/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.png" alt="2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;#region Namespaces
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Newtonsoft.Json.Linq;
using Quobject.SocketIoClientDotNet.Client;
#endregion

namespace Roomedit3dApp
{
  class App : IExternalApplication
  {
    /// &amp;lt;summary&amp;gt;
    /// Caption
    /// &amp;lt;/summary&amp;gt;
    public const string Caption = "Roomedit3d";

    /// &amp;lt;summary&amp;gt;
    /// Socket broadcast URL.
    /// &amp;lt;/summary&amp;gt;
    const string _url = "http://localhost:3000";

    #region External event subscription and handling
    /// &amp;lt;summary&amp;gt;
    /// Store the external event.
    /// &amp;lt;/summary&amp;gt;
    static ExternalEvent _event = null;

    /// &amp;lt;summary&amp;gt;
    /// Store the external event.
    /// &amp;lt;/summary&amp;gt;
    //static BimUpdater _bimUpdater = null;

    static VisibleData _visibleData = null;
    /// &amp;lt;summary&amp;gt;
    /// Store the socket we are listening to.
    /// &amp;lt;/summary&amp;gt;
    static Socket _socket = null;

    /// &amp;lt;summary&amp;gt;
    /// Enqueue a new BIM updater task.
    /// &amp;lt;/summary&amp;gt;
    
    public static void VisibleData(object data)
    {
    JObject data2 = JObject.FromObject(data);
    _visibleData.Enqueue(data2.ToString());
    TaskDialog.Show("abc", data2.ToString());
    _event.Raise();
    }

    /// &amp;lt;summary&amp;gt;
    /// Toggle on and off subscription to automatic 
    /// BIM update from cloud. Return true when subscribed.
    /// &amp;lt;/summary&amp;gt;
    public static bool ToggleSubscription()
    {
      
      if ( null != _event )
      {
        Util.Log( "Unsubscribing..." );

        _socket.Disconnect();
        _socket = null;

        //_bimUpdater = null;
        _visibleData = null;
        _event.Dispose();
        _event = null;

        Util.Log( "Unsubscribed." );
        //Util.Log("Goodbye Tester !");
      }
      else
      {
        Util.Log( "Subscribing..." );

        //_bimUpdater = new BimUpdater();
        _visibleData = new VisibleData();
        var options = new IO.Options()
        {
          IgnoreServerCertificateValidation = true,
          AutoConnect = true,
          ForceNew = true
        };

        _socket = IO.Socket( _url, options );

        _socket.On( Socket.EVENT_CONNECT, () 
          =&amp;gt; Util.Log( "Connected" ) );

        //_socket.On( "transform", data 
        //  =&amp;gt; Enqueue( data ) );
        _socket.On("send-data-from-server", data
            =&amp;gt; VisibleData(data));

        //_event = ExternalEvent.Create( _bimUpdater );
        _event = ExternalEvent.Create(_visibleData);
        Util.Log( "Subscribed." );
        //Util.Log("Hello Tester !");
      }
      //return false;
      return null != _event;
    }
    #endregion // External event subscription and handling

    public Result OnStartup( UIControlledApplication a )
    {

      return Result.Succeeded;
    }

    public Result OnShutdown( UIControlledApplication a )
    {
      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;&amp;nbsp;Here is IExternalEventHandler:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;#region Namespaces
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Events;

#endregion

namespace Roomedit3dApp
{
  /// &amp;lt;summary&amp;gt;
  /// BIM updater, driven both via external 
  /// command and external event handler.
  /// &amp;lt;/summary&amp;gt;
  class VisibleData : IExternalEventHandler
  {
    /// &amp;lt;summary&amp;gt;
    /// The queue of pending tasks consisting 
    /// of UniqueID and translation offset vector.
    /// &amp;lt;/summary&amp;gt;
    Queue&amp;lt;string&amp;gt; _queue = null;

    
    public VisibleData()
    {
      _queue = new Queue&amp;lt;string&amp;gt;();
    }

    /// &amp;lt;summary&amp;gt;
    /// Execute method invoked by Revit via the 
    /// external event as a reaction to a call 
    /// to its Raise method.
    /// &amp;lt;/summary&amp;gt;
   

    public void Execute(UIApplication a)
    {
        Document doc = a.ActiveUIDocument.Document;
        using (Transaction t = new Transaction(doc))
        {
            t.Start("Visible data");

            TaskDialog.Show("Test", _queue.Dequeue());
            t.Commit();
        }
    }
    /// &amp;lt;summary&amp;gt;
    /// Required IExternalEventHandler interface 
    /// method returning a descriptive name.
    /// &amp;lt;/summary&amp;gt;
    public string GetName()
    {
      return App.Caption + " " + GetType().Name;
    }

    /// &amp;lt;summary&amp;gt;
    /// Enqueue a BIM update action to be performed,
    /// consisting of UniqueID and translation 
    /// offset vector.
    /// &amp;lt;/summary&amp;gt;
    public void Enqueue( string uid)
    {
      _queue.Enqueue(uid);
    }
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 08:35:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-connected-and-disconnected-continuity-nodejs-server/m-p/9745259#M31864</guid>
      <dc:creator>mr.engineer.aec</dc:creator>
      <dc:date>2020-09-14T08:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: Revit connected and disconnected continuity nodejs server.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-connected-and-disconnected-continuity-nodejs-server/m-p/9746369#M31865</link>
      <description>&lt;P&gt;Please start from scratch with a simpler sample.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Roomedit3d is far too complex for anyone else to help you with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry, but that is a sample you will have to handle yourself or not at all, as far as I can judge.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to start working with Revit Design Automation and Forge, I would suggest starting our from one of the more recent official samples:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forge.autodesk.com/api/design-automation-cover-page/" target="_blank"&gt;https://forge.autodesk.com/api/design-automation-cover-page/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 18:24:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-connected-and-disconnected-continuity-nodejs-server/m-p/9746369#M31865</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2020-09-14T18:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: Revit connected and disconnected continuity nodejs server.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-connected-and-disconnected-continuity-nodejs-server/m-p/9746901#M31866</link>
      <description>&lt;P&gt;&amp;nbsp;Thank you for the advice. I'll do it.&lt;BR /&gt;I'll comeback roomedit3d later.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Sep 2020 01:23:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-connected-and-disconnected-continuity-nodejs-server/m-p/9746901#M31866</guid>
      <dc:creator>mr.engineer.aec</dc:creator>
      <dc:date>2020-09-15T01:23:58Z</dc:date>
    </item>
  </channel>
</rss>

