void OnDocumentOpened(object sender, DocumentOpenedEventArgs e)
        {
            try
            {
                Document doc = e.Document;
                //string title = doc.Title;
                doc.SaveAsCloudModel(current["folder_id"].AsString, current["file_name"].AsString);
                Console.Write("cualquier cosa");
                if (doc.CanEnableCloudWorksharing())
                {
                    doc.EnableCloudWorksharing();

                    TransactWithCentralOptions    transact = new TransactWithCentralOptions();
                    SynchronizeWithCentralOptions synch    = new SynchronizeWithCentralOptions();
                    synch.Comment = "Autosaved by the API at " + DateTime.Now;
                    RelinquishOptions relinquishOptions = new RelinquishOptions(true);
                    relinquishOptions.CheckedOutElements = true;
                    synch.SetRelinquishOptions(relinquishOptions);

                    doc.SynchronizeWithCentral(transact, synch);
                }
            }
            catch (Exception err)
            {
                Console.Write(err.ToString());
            }
        }
 public static void RegisterServices(object sender, DocumentOpenedEventArgs args)
 {
     foreach (var serv in _services)
     {
         serv.Register(args.Document);
     }
 }
Example #3
0
        /// <summary>
        /// This is the event handler. We modify the model and dump log in this method.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void application_DocumentOpened(object sender, DocumentOpenedEventArgs args)
        {
            // dump the args to log file.
            DumpEventArgs(args);

            // get document from event args.
            Document doc = args.Document;

            if (doc.IsFamilyDocument)
            {
                return;
            }
            try
            {
               //now event framework will not provide transaction,user need start by self(2009/11/18)
               Transaction eventTransaction = new Transaction(doc, "Event handler modify project information");
               eventTransaction.Start();
               // assign specified value to ProjectInformation.Address property.
               // User can change another properties of document or create(delete) something as he likes.
               // Please pay attention that ProjectInformation property is empty for family document.
               // But it isn't the correct usage. So please don't run this sample on family document.
               doc.ProjectInformation.Address =
                   "United States - Massachusetts - Waltham - 610 Lincoln St";
               eventTransaction.Commit();
            }
            catch (Exception ee)
            {
               Trace.WriteLine("Failed to modify project information!-"+ee.Message);
            }
            // write the value to log file to check whether the operation is successful.
            Trace.WriteLine("The value after running the sample ------>");
            Trace.WriteLine("    [Address]         :" + doc.ProjectInformation.Address);
        }
Example #4
0
 private void m_app_DocumentOpened(object sender, DocumentOpenedEventArgs e)
 {
     if (EventsForm.MDocEvents.AreEventsEnabled)
     {
         EventsForm.MDocEvents.EnableEvents(e.Document);
     }
 }
Example #5
0
        public void ShowSidebar(object sender, DocumentOpenedEventArgs args)
        {
            var pane = App.GetDockablePane(Id);

            pane.Show();
            args.Document.Application.DocumentOpened -= ShowSidebar;
        }
Example #6
0
        private void RegisterUpdatersOnOpen(object source, DocumentOpenedEventArgs args)
        {
            try
            {
                if (null != args.Document && !args.IsCancelled())
                {
                    Document doc = args.Document;
                    if (doc.IsWorkshared)
                    {
                        string centralPath = FileInfoUtil.GetCentralFilePath(doc);
                        if (!string.IsNullOrEmpty(centralPath))
                        {
                            //serch for config
                            SingleSessionMonitor.OpenedDocuments.Add(centralPath, doc);

                            LogUtil.AppendLog(centralPath + " Opned.");
                            if (configDictionary.ContainsKey(centralPath))
                            {
                                bool applied = ApplyConfiguration(doc, configDictionary[centralPath]);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtil.AppendLog("RegisterUpdatersOnOpen:" + ex.Message);
            }
        }
Example #7
0
        /// <summary>
        /// This is the event handler. We modify the model and dump log in this method.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void application_DocumentOpened(object sender, DocumentOpenedEventArgs args)
        {
            // dump the args to log file.
            DumpEventArgs(args);

            // get document from event args.
            Document doc = args.Document;

            if (doc.IsFamilyDocument)
            {
                return;
            }
            try
            {
                //now event framework will not provide transaction,user need start by self(2009/11/18)
                Transaction eventTransaction = new Transaction(doc, "Event handler modify project information");
                eventTransaction.Start();
                // assign specified value to ProjectInformation.Address property.
                // User can change another properties of document or create(delete) something as he likes.
                // Please pay attention that ProjectInformation property is empty for family document.
                // But it isn't the correct usage. So please don't run this sample on family document.
                doc.ProjectInformation.Address =
                    "United States - Massachusetts - Waltham - 610 Lincoln St";
                eventTransaction.Commit();
            }
            catch (Exception ee)
            {
                Trace.WriteLine("Failed to modify project information!-" + ee.Message);
            }
            // write the value to log file to check whether the operation is successful.
            Trace.WriteLine("The value after running the sample ------>");
            Trace.WriteLine("    [Address]         :" + doc.ProjectInformation.Address);
        }
Example #8
0
        private void Application_DocumentOpened(object sender, DocumentOpenedEventArgs args)
        {
            if (args.Document == null ||
                (Path.GetTempPath().StartsWith(Path.GetDirectoryName(args.Document.PathName)) &&
                 args.Document.PathName.EndsWith(".ifc.RVT")))
            {
                return;
            }

            try
            {
                openedDocuments.Add(args.Document, new BimbotDocument(args.Document));
                BimbotDocument curDoc = openedDocuments[args.Document];

                DockableResultPanel.DataContext   = curDoc;
                DockableServicesPanel.DataContext = curDoc;
                ExtEvents.ChangeDocumentHandler.documentToUpdate = curDoc;

                //            ActiveDocument = curApp.openedDocuments[args.Document];
                outputPane  = uiApplication.GetDockablePane(OutputPaneId);
                servicePane = uiApplication.GetDockablePane(ServicePaneId);
                ViewToggleButtonResults.IsChecked  = true;
                ViewToggleButtonResults.IsEnabled  = true;
                ViewToggleButtonServices.IsChecked = true;
                ViewToggleButtonServices.IsEnabled = true;
            }
            catch (Exception e)
            {
                MessageBox.Show("Failed to open bimbot part in document due to:\n" + e.Message);
            }
        }
Example #9
0
 /// <summary>
 /// Handler for Revit's DocumentOpened event.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void OnApplicationDocumentOpened(object sender, DocumentOpenedEventArgs e)
 {
     if (revitDynamoModel != null)
     {
         revitDynamoModel.HandleApplicationDocumentOpened();
     }
 }
        public void NotifyModelOpen(object sender, DocumentOpenedEventArgs args)
        {
            // send notification to server
            var state = new UserOpenedModelEvent(args.Document.Title);

            WorksharingMonitorService.PostModelOpenedEvent(state);
        }
Example #11
0
        public void application_DocumentOpened(object sender, DocumentOpenedEventArgs args)
        {
            Document doc = args.Document;
            //add new parameter when a document opens
            Transaction transaction = new Transaction(doc, "Add PhaseGraphics");
            if (transaction.Start() == TransactionStatus.Started)
            {
                var fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Autodesk\Revit\Addins\2012\PhaseSyncSharedParams.txt");
                SetNewParameterToInstances(doc, fileName.ToString());
                transaction.Commit();
            }
            //sync phasegraphics param with Phases of all empty PhaseGraphics objects
            Transaction transaction2 = new Transaction(doc, "Sync PhaseGraphics");
            ICollection<Element> types = null;
            if (transaction2.Start() == TransactionStatus.Started)
            {

                  // Apply the filter to the elements in the active document
                FilteredElementCollector collector = new FilteredElementCollector(doc);
                types = collector.WherePasses(PhaseGraphicsTypeFilter()).ToElements();
                foreach (Element elem in types)

                {
                    //get the phasegraphics parameter from its guid
                    if (elem.get_Parameter(new Guid(PhaseGraphicsGUID)).HasValue == false)
                    {
                        SyncPhaseGraphics(doc, elem);
                    }

                }
                transaction2.Commit();
            }
        }
Example #12
0
 /// <summary>
 /// Dump the events arguments to log file: AutoUpdat.log.
 /// </summary>
 /// <param name="args"></param>
 private void DumpEventArgs(DocumentOpenedEventArgs args)
 {
     Trace.WriteLine("DocumentOpenedEventArgs Parameters ------>");
     Trace.WriteLine("    Event Cancel      : " + args.IsCancelled()); // is it be cancelled?
     Trace.WriteLine("    Event Cancellable : " + args.Cancellable);   // Cancellable
     Trace.WriteLine("    Status            : " + args.Status);        // Status
 }
Example #13
0
        private void OnDocOpened(object sender, DocumentOpenedEventArgs args)
        {
            Autodesk.Revit.ApplicationServices.Application app = (Autodesk.Revit.ApplicationServices.Application)sender;
            Document doc = args.Document;

            app.DocumentChanged += docChange;
        }
Example #14
0
        private void DocumentOpenedAction(object sender, DocumentOpenedEventArgs even)
        {
            settings              = ExtensibleStorage.GetTooltipInfo(even.Document.ProjectInformation);
            this.mysql            = new MysqlUtil(settings);
            this.sqlite           = new SQLiteHelper(settings);
            m_previousDocPathName = even.Document.PathName;
            current_doc           = even.Document;

            //过滤测点待使用
            //打开文档就过滤一次
            keyNameToElementMap = new Dictionary <string, Element>();
            BuiltInParameter       testParam   = BuiltInParameter.ALL_MODEL_TYPE_NAME;
            ParameterValueProvider pvp         = new ParameterValueProvider(new ElementId(testParam));
            FilterStringEquals     eq          = new FilterStringEquals();
            FilterRule             rule        = new FilterStringRule(pvp, eq, Res.String_ParameterSurveyType, false);
            ElementParameterFilter paramFilter = new ElementParameterFilter(rule);
            Document document = current_doc;
            FilteredElementCollector elementCollector = new FilteredElementCollector(document).OfClass(typeof(FamilyInstance));
            IList <Element>          elems            = elementCollector.WherePasses(paramFilter).ToElements();

            foreach (var elem in elems)
            {
                string    param_value = string.Empty;
                Parameter param       = elem.get_Parameter(Res.String_ParameterName);
                if (null != param && param.StorageType == StorageType.String)
                {
                    param_value = param.AsString();
                    if (!string.IsNullOrWhiteSpace(param_value))
                    {
                        keyNameToElementMap.Add(param_value, elem);
                    }
                }
            }


            //准备Material
            IEnumerable <Material> allMaterial = new FilteredElementCollector(even.Document).OfClass(typeof(Material)).Cast <Material>();

            foreach (Material elem in allMaterial)
            {
                if (elem.Name.Equals(Res.String_Color_Redline))
                {
                    color_red = elem;
                }
                if (elem.Name.Equals(Res.String_Color_Gray))
                {
                    color_gray = elem;
                }
                if (elem.Name.Equals(Res.String_Color_Blue))
                {
                    color_blue = elem;
                }
                if (color_gray != null && color_red != null && color_blue != null)
                {
                    this.ColorMaterialIsReady = true;
                    break;
                }
            }
        }
        public static void OnDocumentOpened(object sender, DocumentOpenedEventArgs args)
        {
            var doc             = args.Document;
            var localFileName   = System.IO.Path.GetFileNameWithoutExtension(doc.PathName);
            var centralFileName = System.IO.Path.GetFileNameWithoutExtension(ModelPathUtils.ConvertModelPathToUserVisiblePath(doc.GetWorksharingCentralModelPath()));

            // do stuff with the info you have
        }
Example #16
0
        private void OnDocumentOpened(object sender, DocumentOpenedEventArgs e)
        {
            var doc = e.Document;

            if (doc == null || doc.IsFamilyDocument)
            {
                HideDockablePane();
            }
        }
 private void Application_DocumentOpened(object sender, DocumentOpenedEventArgs e)
 {
     //when a document is opened
     if (DocumentManager.Instance.CurrentUIDocument != null)
     {
         DynamoViewModel.RunEnabled = true;
         ResetForNewDocument();
     }
 }
Example #18
0
        private void OnDocOpened(object sender, DocumentOpenedEventArgs args)
        {
            Autodesk.Revit.ApplicationServices.Application app = (Autodesk.Revit.ApplicationServices.Application)sender;
            Document doc = args.Document;

            //MessageBox.Show("OnDocOpened");
            //打開視圖時觸發

            app.DocumentChanged += docChange;
        }
Example #19
0
        public static void RegisterServices(object sender, DocumentOpenedEventArgs args)
        {
            //var sock = InitializeSocketService(false); // for debugging locally
            var sock = InitializeSocketService();

            foreach (var serv in _services)
            {
                serv.Register(sock, args.Document);
            }
        }
Example #20
0
        public static void OpenedEvent(object sender, DocumentOpenedEventArgs args)
        {
            Document doc = args.Document;

            if (!doc.IsFamilyDocument)
            {
                ProjectStartup(doc);
            }
            //UpdateMFDB.ProjectStartup(args.Document.Application.ActiveAddInId, args.Document);
        }
Example #21
0
        /// <summary>
        /// Called when [document opened].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="Autodesk.Revit.DB.Events.DocumentOpenedEventArgs" /> instance containing the event data.</param>
        private void OnDocumentOpened(object sender, DocumentOpenedEventArgs args)
        {
            // TODO: this is just an example, remove or change code below
            var doc = args.Document;
            Debug.Assert(doc != null, $"Expected a valid Revit {nameof(Document)} instance");

            // TODO: this is just an example, remove or change code below
            var app = args.Document?.Application;
            var uiapp = new UIApplication(app);
            Debug.Assert(uiapp != null, $"Expected a valid Revit {nameof(UIApplication)} instance");
        }
Example #22
0
        /// <summary>
        /// Generic event handler can be subscribed to any events.
        /// It will dump events information(sender and EventArgs) to log window and log file
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="args"></param>
        public void SortLoadedFamiliesParams(Object obj, DocumentOpenedEventArgs args)
        {
            if (!Command.m_SortDialogIsOpened)
            {
                return;
            }

            using (SortLoadedFamiliesParamsForm sortForm = new SortLoadedFamiliesParamsForm(args.Document))
            {
                sortForm.ShowDialog();
            }
        }
Example #23
0
 private void Application_DocumentOpened(object sender, DocumentOpenedEventArgs e)
 {
     /** 數據庫模塊入口
      * Document doc = e.Document;
      * Global.DocContent = new DocumentContent();
      * Global.DataFile = Path.Combine(Path.GetDirectoryName(doc.PathName), $"{Path.GetFileNameWithoutExtension(doc.PathName)}.data");
      * Global.SQLDataFile = Path.Combine(Path.GetDirectoryName(doc.PathName), $"{Path.GetFileNameWithoutExtension(doc.PathName)}.db");
      * Global.DocContent.CurrentDBContext = new SQLContext($"Data Source={Global.SQLDataFile}");
      * Global.DocContent.CurrentDBContext.Database.Create();
      * Global.DocContent.CurrentDBContext.SaveChanges();
      **/
 }
Example #24
0
        //响应处理函数
        public void application_DocumentOpened(object sender, DocumentOpenedEventArgs args)
        {
            //get document object from Event
            Document doc = args.Document;

            using (Transaction trans = new Transaction(doc))
            {
                trans.Start("Edit Address");
                TaskDialog.Show("Infomation", "Event is working");
                //to do...
                trans.Commit();
            }
        }
Example #25
0
        private void Revit_DocumentOpened(object sender, DocumentOpenedEventArgs e)
        {
            var doc = e.Document;

            if (doc == null || doc.IsFamilyDocument)
            {
                return;
            }

            NotifySpeckleFrame("purge-clients", "", "");
            RemoveAllClients();
            InstantiateFileClients();
        }
Example #26
0
 /// <summary>
 /// Handler for Revit's DocumentOpened event.
 /// This handler is called when a document is opened, but NOT when
 /// a document is created from a template.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Application_DocumentOpened(object sender, DocumentOpenedEventArgs e)
 {
     // If the current document is null, for instance if there are
     // no documents open, then set the current document, and
     // present a message telling us where Dynamo is pointing.
     if (DocumentManager.Instance.CurrentUIDocument == null)
     {
         DocumentManager.Instance.CurrentUIDocument = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument;
         dynSettings.DynamoLogger.LogWarning(GetDocumentPointerMessage(), WarningLevel.Moderate);
         DynamoViewModel.RunEnabled = true;
         ResetForNewDocument();
     }
 }
Example #27
0
        private void RegisterSectionUpdaterOnOpen(object source, DocumentOpenedEventArgs args)
        {
            if (args.Document.Title.StartsWith("AssociativeSection"))
              {
             m_sectionUpdater = new SectionUpdater(m_thisAppId);
             m_sectionUpdater.Register(args.Document);

             bool enableSecondUpdate = false;
             if (enableSecondUpdate)
             {
                m_sectionUpdater.UpdateInitialParameters(args.Document);
             }
              }

               args.Document.DocumentClosing += UnregisterSectionUpdaterOnClose;
        }
Example #28
0
        private void RegisterSectionUpdaterOnOpen(object source, DocumentOpenedEventArgs args)
        {
            if (args.Document.Title.StartsWith("AssociativeSection"))
            {
                m_sectionUpdater = new SectionUpdater(m_thisAppId);
                m_sectionUpdater.Register(args.Document);

                bool enableSecondUpdate = false;
                if (enableSecondUpdate)
                {
                    m_sectionUpdater.UpdateInitialParameters(args.Document);
                }
            }

            args.Document.DocumentClosing += UnregisterSectionUpdaterOnClose;
        }
Example #29
0
        private void docOpen(object sender, DocumentOpenedEventArgs e)
        {
            Autodesk.Revit.ApplicationServices.Application app = sender as Autodesk.Revit.ApplicationServices.Application;
            UIApplication uiApp = new UIApplication(app);
            Document      doc   = uiApp.ActiveUIDocument.Document;

            FilteredElementCollector collector = new FilteredElementCollector(doc);

            collector.WherePasses(new ElementClassFilter(typeof(FamilyInstance)));
            var sphereElements = from element in collector where element.Name == "sphere" select element;

            if (sphereElements.Count() == 0)
            {
                TaskDialog.Show("Error", "Sphere family must be loaded");
                return;
            }
            FamilyInstance           sphere        = sphereElements.Cast <FamilyInstance>().First <FamilyInstance>();
            FilteredElementCollector viewCollector = new FilteredElementCollector(doc);
            ICollection <Element>    views         = viewCollector.OfClass(typeof(View3D)).ToElements();
            var viewElements = from element in viewCollector where element.Name == "AVF" select element;

            if (viewElements.Count() == 0)
            {
                TaskDialog.Show("Error", "A 3D view named 'AVF' must exist to run this application.");
                return;
            }
            View view = viewElements.Cast <View>().First <View>();

            SpatialFieldUpdater updater = new SpatialFieldUpdater(uiApp.ActiveAddInId, sphere.Id, view.Id);

            if (!UpdaterRegistry.IsUpdaterRegistered(updater.GetUpdaterId()))
            {
                UpdaterRegistry.RegisterUpdater(updater);
            }
            ElementCategoryFilter wallFilter   = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
            ElementClassFilter    familyFilter = new ElementClassFilter(typeof(FamilyInstance));
            ElementCategoryFilter massFilter   = new ElementCategoryFilter(BuiltInCategory.OST_Mass);
            IList <ElementFilter> filterList   = new List <ElementFilter>();

            filterList.Add(wallFilter);
            filterList.Add(familyFilter);
            filterList.Add(massFilter);
            LogicalOrFilter filter = new LogicalOrFilter(filterList);

            UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), filter, Element.GetChangeTypeGeometry());
            UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), filter, Element.GetChangeTypeElementDeletion());
        }
Example #30
0
 public void OnOpened(object sender, DocumentOpenedEventArgs args)
 {
     try
     {
         Document doc = args.Document;
         if (!CheckTools.AllWorksetsAreOpened(doc))
         {
             return;
         }
         if (doc.IsWorkshared && !doc.IsDetached)
         {
             string   path        = ModelPathUtils.ConvertModelPathToUserVisiblePath(doc.GetWorksharingCentralModelPath());
             FileInfo centralPath = new FileInfo(path);
             foreach (DbDocument dbDoc in KPLNDataBase.DbControll.Documents)
             {
                 FileInfo metaCentralPath = new FileInfo(dbDoc.Path);
                 if (dbDoc.Code == "NONE")
                 {
                     continue;
                 }
                 if (centralPath.FullName == metaCentralPath.FullName)
                 {
                     if (File.Exists(string.Format(@"Z:\Отдел BIM\03_Скрипты\09_Модули_KPLN_Loader\DB\BatchModelCheck\doc_id_{0}.sqlite", dbDoc.Id.ToString())))
                     {
                         List <DbRowData> rows = DbController.GetRows(dbDoc.Id.ToString());
                         if (rows.Count != 0)
                         {
                             if ((DateTime.Now.Day - rows.Last().DateTime.Day > 7 && rows.Last().DateTime.Day != DateTime.Now.Day) || rows.Last().DateTime.Month != DateTime.Now.Month || rows.Last().DateTime.Year != DateTime.Now.Year)
                             {
                                 CheckDocument(doc, dbDoc);
                             }
                         }
                         else
                         {
                             CheckDocument(doc, dbDoc);
                         }
                     }
                     else
                     {
                         CheckDocument(doc, dbDoc);
                     }
                 }
             }
         }
     }
     catch (Exception) { }
 }
Example #31
0
        private static void OnDocumentOpened(object source, DocumentOpenedEventArgs args)
        {
            try
            {
                var doc = args.Document;
                if (doc == null || args.IsCancelled() || doc.IsFamilyDocument)
                {
                    return;
                }

                CheckIn(doc);
            }
            catch (Exception ex)
            {
                Log.AppendLog(LogMessageType.EXCEPTION, ex.Message);
            }
        }
Example #32
0
        private void OnDocumentOpened(object sender, DocumentOpenedEventArgs e)
        {
            try
            {
                var doc = e.Document;
                if (doc == null || e.IsCancelled() || doc.IsFamilyDocument)
                {
                    return;
                }

                CheckIn(doc);
            }
            catch (Exception ex)
            {
                _logger.Fatal(ex);
            }
        }
Example #33
0
        //This runs the events on startup
        public static void starttime(object sender, DocumentOpenedEventArgs args)
        {
            Document currentDoc = args.Document;

            Autodesk.Revit.ApplicationServices.Application uiApp = currentDoc.Application;
            if (!currentDoc.IsFamilyDocument)
            {
                string        fp    = currentDoc.PathName;
                BasicFileInfo bfi   = BasicFileInfo.Extract(fp);
                string        fpath = bfi.CentralPath.Split('\\').Last().Split('.').First();
                string        pnum  = currentDoc.ProjectInformation.Number.ToString();
                EventData     edata = new EventData(pnum);
                edata.DirSetup();

                string[] lines = new string[1];
                string   line  = edata.User + "," + pnum + "," + fpath + "," + edata.Time + ",Open";
                lines[0] = line;

                File.AppendAllLines(edata.FileName, lines);
            }
        }
Example #34
0
        private void docOpen(object sender, DocumentOpenedEventArgs e)
        {
            Autodesk.Revit.ApplicationServices.Application app = sender as Autodesk.Revit.ApplicationServices.Application;
             UIApplication uiApp = new UIApplication(app);
             Document doc = uiApp.ActiveUIDocument.Document;

             FilteredElementCollector collector = new FilteredElementCollector(doc);
             collector.WherePasses(new ElementClassFilter(typeof(FamilyInstance)));
             var sphereElements = from element in collector where element.Name == "sphere" select element;
             if (sphereElements.Count() == 0)
             {
            TaskDialog.Show("Error", "Sphere family must be loaded");
            return;
             }
             FamilyInstance sphere = sphereElements.Cast<FamilyInstance>().First<FamilyInstance>();
             FilteredElementCollector viewCollector = new FilteredElementCollector(doc);
             ICollection<Element> views = viewCollector.OfClass(typeof(View3D)).ToElements();
             var viewElements = from element in viewCollector where element.Name == "AVF" select element;
             if (viewElements.Count() == 0)
             {
            TaskDialog.Show("Error", "A 3D view named 'AVF' must exist to run this application.");
            return;
             }
             View view = viewElements.Cast<View>().First<View>();

             SpatialFieldUpdater updater = new SpatialFieldUpdater(uiApp.ActiveAddInId, sphere.Id, view.Id);
             if (!UpdaterRegistry.IsUpdaterRegistered(updater.GetUpdaterId())) UpdaterRegistry.RegisterUpdater(updater);
             ElementCategoryFilter wallFilter = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
             ElementClassFilter familyFilter = new ElementClassFilter(typeof(FamilyInstance));
             ElementCategoryFilter massFilter = new ElementCategoryFilter(BuiltInCategory.OST_Mass);
             IList<ElementFilter> filterList = new List<ElementFilter>();
             filterList.Add(wallFilter);
             filterList.Add(familyFilter);
             filterList.Add(massFilter);
             LogicalOrFilter filter = new LogicalOrFilter(filterList);

             UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), filter, Element.GetChangeTypeGeometry());
             UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), filter, Element.GetChangeTypeElementDeletion());
        }
Example #35
0
 /// <summary>
 /// Handler for Revit's DocumentOpened event.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void OnApplicationDocumentOpened(object sender, DocumentOpenedEventArgs e)
 {
     if (revitDynamoModel != null)
     {
         revitDynamoModel.HandleApplicationDocumentOpened();
     }
 }
Example #36
0
 /// <summary>
 /// Handler for Revit's DocumentOpened event.
 /// This handler is called when a document is opened, but NOT when
 /// a document is created from a template.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Application_DocumentOpened(object sender, DocumentOpenedEventArgs e)
 {
     // If the current document is null, for instance if there are
     // no documents open, then set the current document, and 
     // present a message telling us where Dynamo is pointing.
     if (DocumentManager.Instance.CurrentUIDocument == null)
     {
         DocumentManager.Instance.CurrentUIDocument = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument;
         dynSettings.DynamoLogger.LogWarning(GetDocumentPointerMessage(), WarningLevel.Moderate);
         DynamoViewModel.RunEnabled = true;
         ResetForNewDocument();
     }
 }
Example #37
0
 /// <summary>
 /// Dump the events arguments to log file: AutoUpdat.log.
 /// </summary>
 /// <param name="args"></param>
 private void DumpEventArgs(DocumentOpenedEventArgs args)
 {
     Trace.WriteLine("DocumentOpenedEventArgs Parameters ------>");
     Trace.WriteLine("    Event Cancel      : " + args.IsCancelled()); // is it be cancelled?
     Trace.WriteLine("    Event Cancellable : " + args.Cancellable); // Cancellable
     Trace.WriteLine("    Status            : " + args.Status); // Status
 }
 private void OnDocumentOpened(object sender, DocumentOpenedEventArgs e)
 {
     try
     {
         InitModel(e.Document);
     }
     catch (Exception ex)
     {
         TaskDialog.Show("Error", ex.Message);
     }
 }
Example #39
0
 private void DocumentOpened(object sender, DocumentOpenedEventArgs e)
 {
     var doc = e.Document;
     _sessionManager.InitialiseSession(doc);
 }
  public void application_DocumentOpened(object sender, DocumentOpenedEventArgs args)
  {
   //从事件参数中获得文档对象
   Document doc = args.Document;

   Transaction transaction = new Transaction(doc, "Edit Address");
   if (transaction.Start() == TransactionStatus.Started)
   {
    doc.ProjectInformation.Address =
       "United States - Massachusetts - Waltham - 1560 Trapelo Road";
    transaction.Commit();
   }
  }
 private void Application_DocumentOpened(object sender, DocumentOpenedEventArgs e)
 {
     //when a document is opened 
     if (DocumentManager.Instance.CurrentUIDocument != null)
     {
         DynamoViewModel.RunEnabled = true;
         ResetForNewDocument();
     }
 }