Пример #1
0
        //reate and Register Dynamic Model Updaters with the Current Session of Revit. It should only need to be registered one time per session, and affects
        //all documents opened there after
        private Result RegisterUpdaters(UIControlledApplication RevitApplication)
        {
            try
            {
                //Create a new instance of the ViewSheetUpdater Class and Pass the ActiveAddInId for this Application
                Updaters.ViewSheetUpdater viewSheetUpdater = new Updaters.ViewSheetUpdater(RevitApplication.ActiveAddInId);
                //Register the Updater for this Session of Revit. The IsOption bool at the end allows the modifications of the updater to persist even if another user
                //doesnt have the same add-in (For paid / propriatary add-in like Autodesk Subcription itsm)
                UpdaterRegistry.RegisterUpdater(viewSheetUpdater, true);
                //Filter the items being "watched" to just ViewSheets so we use a class filter
                ElementClassFilter viewSheetFilter = new ElementClassFilter(typeof(ViewSheet));
                //Add a trigger to the Updater so Revit knows When to execute the Updater. Here it is set for Element Addition
                //which is when a new sheet is created.
                UpdaterRegistry.AddTrigger(viewSheetUpdater.GetUpdaterId(), viewSheetFilter, Element.GetChangeTypeElementAddition());
                //This Method is set up as a Result becuase you may need to Unregister and Re-Register the updaters for other portions of the App and
                //it is good to know if it all worked or not
                return(Result.Succeeded);
            }

            //Catch any exceptions and present them to the User
            catch (Exception ex)
            {
                TaskDialog.Show("Error Registering Updaters", ex.ToString());
                return(Result.Failed);
            }
        }
Пример #2
0
 //Disable Dynamic Model Updaters within the Current Session of Revit. This is useful when another tool may be stopped or interupted by an Updater
 internal static Result DisableUpdaters(UIControlledApplication RevitApplication)
 {
     try
     {
         //Create a new instance of the ViewSheetUpdater Class and Pass the ActiveAddInId for this Application
         Updaters.ViewSheetUpdater sheetUpdater = new Updaters.ViewSheetUpdater(RevitApplication.ActiveAddInId);
         //Disable the updater. It will not execute again until it is Enabled
         UpdaterRegistry.DisableUpdater(sheetUpdater.GetUpdaterId());
         //Return the Result
         return(Result.Succeeded);
     }
     //Catch any exceptions and present them to the User
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(Result.Failed);
     }
 }
Пример #3
0
 //Enable Dynamic Model Updaters within the Current Session of Revit. This is to be used when one or more Updaters were Disabled programatically
 internal static Result EnableUpdaters(UIControlledApplication RevitApplication)
 {
     try
     {
         //Create a new instance of the ViewSheetUpdater Class and Pass the ActiveAddInId for this Application
         Updaters.ViewSheetUpdater viewSheetUpdater = new Updaters.ViewSheetUpdater(RevitApplication.ActiveAddInId);
         //Enable the updater once it is registered, or if it has been disabled by another Method or Class programatically
         UpdaterRegistry.EnableUpdater(viewSheetUpdater.GetUpdaterId());
         //Return the result
         return(Result.Succeeded);
     }
     //Catch any exceptions and present them to the User
     catch (Exception ex)
     {
         TaskDialog.Show("Error Enabling Updaters", ex.ToString());
         return(Result.Failed);
     }
 }
Пример #4
0
 //Unregister Dynamic Model Updaters with the Current Session of Revit to clean things up on Exit
 private Result UnregisterUpdaters(UIControlledApplication RevitApplication)
 {
     try
     {
         //Create a new instance of the ViewSheetUpdater Class and Pass the ActiveAddInId for this Application
         Updaters.ViewSheetUpdater viewSheetUpdater = new Updaters.ViewSheetUpdater(RevitApplication.ActiveAddInId);
         //Unregister the Updater from the Updater Registry using the UpdaterId
         UpdaterRegistry.UnregisterUpdater(viewSheetUpdater.GetUpdaterId());
         //Return the result
         return(Result.Succeeded);
     }
     //Catch any exceptions and present them to the User
     catch (Exception ex)
     {
         TaskDialog.Show("Error Unregistering Updaters", ex.ToString());
         return(Result.Failed);
     }
 }