示例#1
0
        /// <summary>
        /// Handles removal of updaters when Document closes.
        /// </summary>
        public void DocumentClosing(object sender, DocumentClosingEventArgs args)
        {
            try
            {
                var doc = args.Document;
                if (null == doc)
                {
                    return;
                }

                var centralPath = RevitUtil.GetCentralFilePath(doc);
                if (!configDictionary.ContainsKey(centralPath))
                {
                    return;
                }

                var config = configDictionary[centralPath];
                UpdaterUtil.UnregisterUpdaters(doc, config);
                configDictionary.Remove(centralPath);
            }
            catch (Exception ex)
            {
                Log.AppendLog(LogMessageType.EXCEPTION, ex.Message);
            }
        }
示例#2
0
        public void ShowWindow(UIApplication uiapp)
        {
            try
            {
                if (mainWindow != null)
                {
                    return;
                }

                var doc         = uiapp.ActiveUIDocument.Document;
                var centralPath = RevitUtil.GetCentralFilePath(doc);
                SheetManagerConfiguration config;
                if (configDictionary.ContainsKey(centralPath))
                {
                    config = configDictionary[centralPath];
                }
                else
                {
                    config = new SheetManagerConfiguration(doc);
                    configDictionary.Add(config.CentralPath, config);
                }

                var viewModel = new AddInViewModel(config)
                {
                    Handler = new SheetManagerHandler(uiapp)
                };
                viewModel.ExtEvent = ExternalEvent.Create(viewModel.Handler);

                SheetUpdater.IsSheetManagerOn    = true;
                RevisionUpdater.IsSheetManagerOn = true;

                mainWindow = new MainWindow
                {
                    DataContext = viewModel
                };
                mainWindow.Closed += WindowClosed;
                mainWindow.Show();
            }
            catch (Exception ex)
            {
                Log.AppendLog(LogMessageType.EXCEPTION, ex.Message);
            }
        }
        public SheetManagerConfiguration(Document doc)
        {
            try
            {
                modelId     = Guid.NewGuid();
                centralPath = RevitUtil.GetCentralFilePath(doc);

                FilteredElementCollector collector  = new FilteredElementCollector(doc);
                List <ElementId>         elementIds = collector.OfCategory(BuiltInCategory.OST_TitleBlocks).WhereElementIsElementType().ToElementIds().ToList();
                if (elementIds.Count > 0)
                {
                    titleblockId = elementIds.First();
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
        }