Example #1
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            try
            {
                ExternalEventHandler eventHandler  = new ExternalEventHandler();
                ExternalEvent        externalEvent = ExternalEvent.Create(eventHandler);

                var mainWindow = new ServerView(uidoc, eventHandler, externalEvent);
                var helper     = new WindowInteropHelper(mainWindow)
                {
                    Owner = ComponentManager.ApplicationWindow
                };

                mainWindow.Show();
            }
            catch (Exception e)
            {
                e.ShowRevitDialog();
                return(Result.Failed);
            }

            return(Result.Succeeded);
        }
Example #2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            if (commandData.Application.ActiveUIDocument.Document.IsFamilyDocument)
            {
                MessageBox.Show("Вы открыли семейство", "Ошибка");
                return(Result.Cancelled);
            }

            //Создаем экземпляр модели
            Model model = new Model(uiapp);
            //Создаем экземпляр презентации-модели
            ViewModelItems viewmodel = new ViewModelItems();
            //Создаем экземпляр внешней транзакции и передаем в него созданную модель
            ExternalEventHandler externalEventHandlerButton = new ExternalEventHandler(model);
            //Создаем внешнее событие и добавляем внешнюю транзакцию
            ExternalEvent ExEvent = ExternalEvent.Create(externalEventHandlerButton);

            //Передаем созданную модель во ViewModel
            viewmodel.RevitModel = model;
            //Добавляем во ViewModel внешнее событие
            viewmodel.ApplyEvent = ExEvent;
            //Создаем экземпляр формы
            var mainFilterView = new filterViewForm();

            mainFilterView.DataContext = viewmodel;
            mainFilterView.ShowDialog();
            return(Result.Succeeded);
        }
Example #3
0
        public ServerView(UIDocument uidoc, ExternalEventHandler eventHandler, ExternalEvent externalEvent)
        {
            _eventHandler  = eventHandler;
            _externalEvent = externalEvent;
            _doc           = uidoc.Document;
            InitializeComponent();

            _server = new IpcServer();
            _server.ReceivedRequest += ServerOnReceivedRequest;
        }
Example #4
0
        public SnS(Autodesk.Revit.UI.ExternalEvent exEvent,
                   ExternalEventHandler handler,
                   ModelessForms.Application thisApp)
        {
            InitializeComponent();

            m_ExEvent = exEvent;
            m_Handler = handler;
            ThisApp   = thisApp;

            //Initialize treeview path separator
            treeView1.PathSeparator = ".";

            //Log
            LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration("G:\\Github\\shtirlitsDva\\MyRevitAddins\\MyRevitAddins\\SetTagsModeless\\NLog.config");

            //Setup a rudimentary list with categories
            string[] cats = { "Pipes", "Pipe Fittings", "Pipe Accessories" };
            checkedListBox2.Items.Clear();
            checkedListBox2.Items.AddRange(cats);

            Grouping grouping = mySettings.Default.GroupingSettings;

            if (grouping != null)
            {
                Payload.Grouping = grouping;
            }

            //Initialize settings for categories
            if (mySettings.Default.SelectedCategories != null)
            {
                SelectedCategories = mySettings.Default.SelectedCategories;
                if (SelectedCategories.Count != 0)
                {
                    foreach (string cat in SelectedCategories)
                    {
                        SetItemChecked(cat, checkedListBox2);
                    }
                }
                Payload.CategoriesToSearch = SelectedCategories;

                //Request Revit for parameter information
                AsyncGatherParameterData asGPD = new AsyncGatherParameterData(Payload);
                ThisApp.asyncCommand = asGPD;
                m_ExEvent.Raise();
                Payload.GetParameterDataOperationComplete += GetParameterDataOperationComplete;
                button2.Text = "Loading parameter data...";
            }
        }