Ejemplo n.º 1
0
        private void UnregisterViewportUpdaterOnClose(object source, DocumentClosingEventArgs args)
        {
            //idsToWatch.Clear();
            //m_oldSectionId = ElementId.InvalidElementId;

            if (m_viewportUpdater != null)
            {
                UpdaterRegistry.UnregisterUpdater(m_viewportUpdater.GetUpdaterId());
                m_viewportUpdater = null;
            }
        }
Ejemplo n.º 2
0
        public Result Execute(UIApplication uiapp)
        {
            try
            {
                m_documentUI = uiapp.ActiveUIDocument;
                m_document   = m_documentUI.Document;
                m_thisAppId  = uiapp.Application.ActiveAddInId;

                // creating and registering the updater for the document.
                if (m_viewportUpdater == null)
                {
                    using (Transaction t = new Transaction(m_document, "Register Drawing Cell Updater"))
                    {
                        t.Start();

                        m_viewportUpdater = new ViewportUpdater(m_thisAppId);
                        m_viewportUpdater.Register(m_document);

                        t.Commit();
                    }
                }

                //Find all viewports to watch if they move
                ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_Viewports);

                UpdaterRegistry.RemoveAllTriggers(m_viewportUpdater.GetUpdaterId());
                m_viewportUpdater.AddTriggerForUpdater(m_document, filter);


                m_document.DocumentClosing += UnregisterViewportUpdaterOnClose;
                return(Result.Succeeded);
            }
            catch
            {
                return(Result.Failed);
            }
        }