/// <inheritdoc/>
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
#if !DEBUG
                ModPlusAPI.Statistic.SendCommandStarting(ModPlusConnector.Instance);
#endif

                if (RenamerWindow == null)
                {
                    var mainVm = new MainViewModel(new RevitService(commandData.Application.Application, new RevitEvent()));
                    RenamerWindow = new RenamerWindow {
                        DataContext = mainVm
                    };
                    RenamerWindow.Closed += (sender, args) => RenamerWindow = null;
                    RenamerWindow.Show();
                }
                else
                {
                    RenamerWindow.Activate();
                }
            }
            catch (Exception exception)
            {
                ExceptionBox.Show(exception);
                return(Result.Failed);
            }

            return(Result.Succeeded);
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                var app           = commandData.Application.Application;
                var revitEvent    = new RevitEvent();
                var revitService  = new RevitService(app, revitEvent);
                var mainVm        = new MainVm(revitService);
                var renamerWindow = new RenamerWindow()
                {
                    DataContext = mainVm
                };
                renamerWindow.Show();
            }
            catch (PluginException e)
            {
                message = e.Message;
                if (e.Elements.Count > 0)
                {
                    foreach (var element in e.Elements)
                    {
                        elements.Insert(element);
                    }
                }

                return(Result.Failed);
            }
            catch (Exception e)
            {
                message = e.Message;
                return(Result.Failed);
            }

            return(Result.Succeeded);
        }
Exemplo n.º 3
0
        private void RenameElement(object parameter)
        {
            //Creator.ChangeID(
            //bring up a window to change the id. once the id is set, confirm it
            RenamerWindow dlg = new RenamerWindow("Rename Element", Creator.Name);

            dlg.ShowDialog();
            if (dlg.DialogResult == true)
            {
                //attempt to rename
                try
                {
                    Creator.ChangeID(dlg.NewName);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
            }
        }