public void InitTransaction()
        {
            if (_trans == null || _trans.GetStatus() != TransactionStatus.Started)
            {
                _trans = new Autodesk.Revit.DB.Transaction(dynRevitSettings.Doc.Document, "Dynamo Script");
                _trans.Start();

                FailureHandlingOptions failOpt = _trans.GetFailureHandlingOptions();
                failOpt.SetFailuresPreprocessor(new DynamoWarningPrinter());
                _trans.SetFailureHandlingOptions(failOpt);
            }
        }
Example #2
0
        public override void ShutDown()
        {
            IdlePromise.ExecuteOnShutdown(
                delegate
            {
                var transaction = new Autodesk.Revit.DB.Transaction(dynRevitSettings.Doc.Document, "Dynamo Script");
                transaction.Start();

                if (_keeperId != ElementId.InvalidElementId)
                {
                    dynRevitSettings.Doc.Document.Delete(_keeperId);
                    _keeperId = ElementId.InvalidElementId;
                }

                transaction.Commit();
            });

            base.ShutDown();
            Updater.UnRegisterAllChangeHooks();
            RevertPythonBindings();
        }
        public override void ShutDown(bool shutDownHost)
        {
            IdlePromise.ExecuteOnShutdown(
                delegate
            {
                var transaction = new Autodesk.Revit.DB.Transaction(dynRevitSettings.Doc.Document, "Dynamo Script");
                transaction.Start();

                if (_keeperId != ElementId.InvalidElementId)
                {
                    dynRevitSettings.Doc.Document.Delete(_keeperId);
                    _keeperId = ElementId.InvalidElementId;
                }

                transaction.Commit();
            });

            base.ShutDown(shutDownHost);
            Updater.UnRegisterAllChangeHooks();
            RevertPythonBindings();

            if (shutDownHost)
            {
                //shut down revit
                var exitCommand = RevitCommandId.LookupPostableCommandId(PostableCommand.ExitRevit);
                var uiapp       = dynRevitSettings.Revit.ActiveUIDocument.Application;
                if (uiapp.CanPostCommand(exitCommand))
                {
                    uiapp.PostCommand(exitCommand);
                }
                else
                {
                    MessageBox.Show(
                        "A command in progress prevented Dynamo from closing revit. Dynamo update will be cancelled.");
                }
            }
        }
        public override void ShutDown(bool shutDownHost)
        {
            IdlePromise.ExecuteOnShutdown(
                delegate
                    {
                        var transaction = new Autodesk.Revit.DB.Transaction(dynRevitSettings.Doc.Document, "Dynamo Script");
                        transaction.Start();

                        if (_keeperId != ElementId.InvalidElementId)
                        {
                            dynRevitSettings.Doc.Document.Delete(_keeperId);
                            _keeperId = ElementId.InvalidElementId;
                        }

                        transaction.Commit();
                    });

            base.ShutDown(shutDownHost);
            Updater.UnRegisterAllChangeHooks();
            RevertPythonBindings();

            if (shutDownHost)
            {
                //shut down revit
                var exitCommand = RevitCommandId.LookupPostableCommandId(PostableCommand.ExitRevit);
                var uiapp = dynRevitSettings.Revit.ActiveUIDocument.Application;
                if (uiapp.CanPostCommand(exitCommand))
                {
                    uiapp.PostCommand(exitCommand);
                }
                else
                {
                    MessageBox.Show(
                        "A command in progress prevented Dynamo from closing revit. Dynamo update will be cancelled.");
                }
            }
        }
        public void InitTransaction()
        {
            if (_trans == null || _trans.GetStatus() != TransactionStatus.Started)
            {
                _trans = new Autodesk.Revit.DB.Transaction(dynRevitSettings.Doc.Document, "Dynamo Script");
                _trans.Start();

                FailureHandlingOptions failOpt = _trans.GetFailureHandlingOptions();
                failOpt.SetFailuresPreprocessor(new DynamoWarningPrinter());
                _trans.SetFailureHandlingOptions(failOpt);
            }
        }
        public override void ShutDown()
        {
            IdlePromise.ExecuteOnShutdown(
                delegate
                    {
                        var transaction = new Autodesk.Revit.DB.Transaction(dynRevitSettings.Doc.Document, "Dynamo Script");
                        transaction.Start();

                        if (_keeperId != ElementId.InvalidElementId)
                        {
                            dynRevitSettings.Doc.Document.Delete(_keeperId);
                            _keeperId = ElementId.InvalidElementId;
                        }

                        transaction.Commit();
                    });

            base.ShutDown();
            Updater.UnRegisterAllChangeHooks();
            RevertPythonBindings();
        }