Esempio n. 1
0
        public Result OnStartup(UIControlledApplication a)
        {
            //add the UI button on start up
            AddButtons(a);

            //Register sheet updater with Revit
            RenameViewUpdater updater = new RenameViewUpdater(a.ActiveAddInId);
            UpdaterRegistry.RegisterUpdater(updater);
            UpdaterRegistry.SetIsUpdaterOptional(updater.GetUpdaterId(), true);

            //filter by Class
            ElementClassFilter sheet = new ElementClassFilter(typeof(ViewSheet));
            ElementClassFilter viewPort = new ElementClassFilter(typeof(Viewport));
            ElementClassFilter view = new ElementClassFilter(typeof(View));
            ElementCategoryFilter viewPortFilter = new ElementCategoryFilter(BuiltInCategory.OST_Viewports);
            ElementCategoryFilter viewFilter = new ElementCategoryFilter(BuiltInCategory.OST_Views);

            LogicalOrFilter filter = new LogicalOrFilter(viewPortFilter, viewFilter);

            //Paramter to send to the trigger
            ElementId sheetId = new ElementId(BuiltInParameter.SHEET_NUMBER);

            ElementId viewPortNumberId = new ElementId(BuiltInParameter.VIEWPORT_DETAIL_NUMBER);
            ElementId viewPortNameId = new ElementId(BuiltInParameter.VIEWPORT_VIEW_NAME);
            ElementId titleOnSheetId = new ElementId(BuiltInParameter.VIEW_DESCRIPTION);
            ElementId viewPortSheetNumber = new ElementId(BuiltInParameter.VIEWPORT_SHEET_NUMBER);

            //Set trigger to send to execute when modified
            UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), sheet, Element.GetChangeTypeParameter(sheetId));
            UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), viewPort, Element.GetChangeTypeParameter(viewPortNumberId));
            UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), view, Element.GetChangeTypeParameter(viewPortNameId));
            UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), view, Element.GetChangeTypeParameter(titleOnSheetId));

            //Set trigger to send when added
            UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), filter, Element.GetChangeTypeElementAddition());

            return Result.Succeeded;
        }
Esempio n. 2
0
 public Result OnShutdown(UIControlledApplication a)
 {
     RenameViewUpdater updater = new RenameViewUpdater(a.ActiveAddInId);
     UpdaterRegistry.UnregisterUpdater(updater.GetUpdaterId());
     return Result.Succeeded;
 }