UpdateBim() public method

Apply all current cloud database changes to the BIM.
public UpdateBim ( ) : void
return void
コード例 #1
0
    public Result Execute(
      ExternalCommandData commandData,
      ref string message,
      ElementSet elements )
    {
      UIApplication uiapp = commandData.Application;
      UIDocument uidoc = uiapp.ActiveUIDocument;
      Application app = uiapp.Application;
      Document doc = uidoc.Document;

      if( null == doc )
      {
        Util.ErrorMsg( "Please run this command in a valid"
          + " Revit project document." );
        return Result.Failed;
      }

      if( -1 == DbUpdater.LastSequence )
      {
        DbUpdater.SetLastSequence();

        return Result.Succeeded;
      }

      //// Retrieve all room unique ids in model:

      //FilteredElementCollector rooms 
      //  = new FilteredElementCollector( doc )
      //    .OfClass( typeof( SpatialElement ) )
      //    .OfCategory( BuiltInCategory.OST_Rooms );

      //IEnumerable<string> roomUniqueIds 
      //  = rooms.Select<Element, string>( 
      //    e => e.UniqueId );

      ////string ids = "?keys=[%22" + string.Join(
      ////  "%22,%22", roomUniqueIds ) + "%22]";

      //// Retrieve furniture transformations 
      //// after last sequence number:

      //CouchDatabase db = new RoomEditorDb().Db;

      //ChangeOptions opt = new ChangeOptions();

      //opt.IncludeDocs = true;
      //opt.Since = LastSequence;
      //opt.View = "roomedit/map_room_to_furniture";

      //// I tried to add a filter to this view, but 
      //// that is apparently not supported by the 
      //// CouchDB or DreamSeat GetChanges functionality.
      ////+ ids; // failed attempt to filter view by room id keys

      //// Specify filter function defined in 
      //// design document to get updates
      ////opt.Filter = 

      //CouchChanges<DbFurniture> changes
      //  = db.GetChanges<DbFurniture>( opt );

      //CouchChangeResult<DbFurniture>[] results 
      //  = changes.Results;

      //DbUpdater updater = new DbUpdater( 
      //  doc, roomUniqueIds );

      //foreach( CouchChangeResult<DbFurniture> result
      //  in results )
      //{
      //  updater.UpdateBimFurniture( result.Doc );

      //  LastSequence = result.Sequence;
      //}

      //DbUpdater updater = new DbUpdater( doc );

      DbUpdater updater = new DbUpdater( uiapp );

      updater.UpdateBim();

      return Result.Succeeded;
    }
コード例 #2
0
ファイル: CmdUpdate.cs プロジェクト: vdubya/RoomEditorApp
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            if (null == doc)
            {
                Util.ErrorMsg("Please run this command in a valid"
                              + " Revit project document.");
                return(Result.Failed);
            }

            if (-1 == DbUpdater.LastSequence)
            {
                DbUpdater.SetLastSequence();

                return(Result.Succeeded);
            }

            //// Retrieve all room unique ids in model:

            //FilteredElementCollector rooms
            //  = new FilteredElementCollector( doc )
            //    .OfClass( typeof( SpatialElement ) )
            //    .OfCategory( BuiltInCategory.OST_Rooms );

            //IEnumerable<string> roomUniqueIds
            //  = rooms.Select<Element, string>(
            //    e => e.UniqueId );

            ////string ids = "?keys=[%22" + string.Join(
            ////  "%22,%22", roomUniqueIds ) + "%22]";

            //// Retrieve furniture transformations
            //// after last sequence number:

            //CouchDatabase db = new RoomEditorDb().Db;

            //ChangeOptions opt = new ChangeOptions();

            //opt.IncludeDocs = true;
            //opt.Since = LastSequence;
            //opt.View = "roomedit/map_room_to_furniture";

            //// I tried to add a filter to this view, but
            //// that is apparently not supported by the
            //// CouchDB or DreamSeat GetChanges functionality.
            ////+ ids; // failed attempt to filter view by room id keys

            //// Specify filter function defined in
            //// design document to get updates
            ////opt.Filter =

            //CouchChanges<DbFurniture> changes
            //  = db.GetChanges<DbFurniture>( opt );

            //CouchChangeResult<DbFurniture>[] results
            //  = changes.Results;

            //DbUpdater updater = new DbUpdater(
            //  doc, roomUniqueIds );

            //foreach( CouchChangeResult<DbFurniture> result
            //  in results )
            //{
            //  updater.UpdateBimFurniture( result.Doc );

            //  LastSequence = result.Sequence;
            //}

            //DbUpdater updater = new DbUpdater( doc );

            DbUpdater updater = new DbUpdater(uiapp);

            updater.UpdateBim();

            return(Result.Succeeded);
        }
コード例 #3
0
        /// <summary>
        /// Wait far a moment before requerying database.
        /// </summary>
        //static Stopwatch _stopwatch = null;

        void OnIdling(
            object sender,
            IdlingEventArgs ea)
        {
            using (JtTimer pt = new JtTimer("OnIdling"))
            {
                // Use with care! This loads the CPU:

                ea.SetRaiseWithoutDelay();

                ++_counter;

                if (0 == (_counter % _update_interval))
                {
                    if (0 == (_counter % _message_interval))
                    {
                        Util.Log(string.Format(
                                     "OnIdling called {0} times",
                                     _counter));
                    }

                    // Have we waited long enough since the last attempt?

                    //if( null == _stopwatch
                    //  || _stopwatch.ElapsedMilliseconds > 500 )

                    RoomEditorDb rdb = new RoomEditorDb();
                    //int n = rdb.LastSequenceNumber;

                    if (rdb.LastSequenceNumberChanged(
                            DbUpdater.LastSequence))
                    {
                        UIApplication uiapp = sender as UIApplication;
                        Document      doc   = uiapp.ActiveUIDocument.Document;

                        Util.Log("furniture update begin");

                        //FilteredElementCollector rooms
                        //  = new FilteredElementCollector( doc )
                        //    .OfClass( typeof( SpatialElement ) )
                        //    .OfCategory( BuiltInCategory.OST_Rooms );

                        //IEnumerable<string> roomUniqueIds
                        //  = rooms.Select<Element, string>(
                        //    e => e.UniqueId );

                        //CouchDatabase db = rdb.Db;

                        //ChangeOptions opt = new ChangeOptions();

                        //opt.IncludeDocs = true;
                        //opt.Since = CmdUpdate.LastSequence;
                        //opt.View = "roomedit/map_room_to_furniture";

                        //CouchChanges<DbFurniture> changes
                        //  = db.GetChanges<DbFurniture>( opt );

                        //CouchChangeResult<DbFurniture>[] results
                        //  = changes.Results;

                        //DbUpdater updater = new DbUpdater(
                        //  doc, roomUniqueIds );

                        //foreach( CouchChangeResult<DbFurniture> result
                        //  in results )
                        //{
                        //  updater.UpdateBimFurniture( result.Doc );

                        //  CmdUpdate.LastSequence = result.Sequence;
                        //}

                        DbUpdater updater = new DbUpdater(uiapp);

                        updater.UpdateBim();

                        Util.Log("furniture update end");

                        //  _stopwatch = new Stopwatch();
                        //  _stopwatch.Start();
                        //}
                        //catch( Exception ex )
                        //{
                        //  //uiapp.Application.WriteJournalComment

                        //  Debug.Print(
                        //    "Room Editor: an error occurred "
                        //    + "executing the OnIdling event:\r\n"
                        //    + ex.ToString() );

                        //  Debug.WriteLine( ex );
                        //}
                    }
                }
            }
        }
コード例 #4
0
    /// <summary>
    /// Wait far a moment before requerying database.
    /// </summary>
    //static Stopwatch _stopwatch = null;

    void OnIdling(
      object sender,
      IdlingEventArgs ea )
    {
      using( JtTimer pt = new JtTimer( "OnIdling" ) )
      {
        // Use with care! This loads the CPU:

        ea.SetRaiseWithoutDelay();

        ++_counter;

        if( 0 == ( _counter % _update_interval ) )
        {
          if( 0 == ( _counter % _message_interval ) )
          {
            Util.Log( string.Format(
              "OnIdling called {0} times",
              _counter ) );
          }

          // Have we waited long enough since the last attempt?

          //if( null == _stopwatch
          //  || _stopwatch.ElapsedMilliseconds > 500 )

          RoomEditorDb rdb = new RoomEditorDb();
          //int n = rdb.LastSequenceNumber;

          if( rdb.LastSequenceNumberChanged(
            DbUpdater.LastSequence ) )
          {
            UIApplication uiapp = sender as UIApplication;
            Document doc = uiapp.ActiveUIDocument.Document;

            Util.Log( "furniture update begin" );

            //FilteredElementCollector rooms
            //  = new FilteredElementCollector( doc )
            //    .OfClass( typeof( SpatialElement ) )
            //    .OfCategory( BuiltInCategory.OST_Rooms );

            //IEnumerable<string> roomUniqueIds
            //  = rooms.Select<Element, string>(
            //    e => e.UniqueId );

            //CouchDatabase db = rdb.Db;

            //ChangeOptions opt = new ChangeOptions();

            //opt.IncludeDocs = true;
            //opt.Since = CmdUpdate.LastSequence;
            //opt.View = "roomedit/map_room_to_furniture";

            //CouchChanges<DbFurniture> changes
            //  = db.GetChanges<DbFurniture>( opt );

            //CouchChangeResult<DbFurniture>[] results
            //  = changes.Results;

            //DbUpdater updater = new DbUpdater(
            //  doc, roomUniqueIds );

            //foreach( CouchChangeResult<DbFurniture> result
            //  in results )
            //{
            //  updater.UpdateBimFurniture( result.Doc );

            //  CmdUpdate.LastSequence = result.Sequence;
            //}

            DbUpdater updater = new DbUpdater( uiapp );

            updater.UpdateBim();

            Util.Log( "furniture update end" );

            //  _stopwatch = new Stopwatch();
            //  _stopwatch.Start();
            //}
            //catch( Exception ex )
            //{
            //  //uiapp.Application.WriteJournalComment

            //  Debug.Print(
            //    "Room Editor: an error occurred "
            //    + "executing the OnIdling event:\r\n"
            //    + ex.ToString() );

            //  Debug.WriteLine( ex );
            //}
          }
        }
      }
    }