Example #1
0
        public RevitService(Application app, RevitEvent @event)
        {
            _app   = app;
            _event = @event;

            SetupProvides();
        }
        public RevitService(Autodesk.Revit.ApplicationServices.Application app, RevitEvent revitEvent)
        {
            _app        = app;
            _revitEvent = revitEvent;

            SetupProvides();
        }
        /// <inheritdoc />
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
#if !DEBUG
            Statistic.SendCommandStarting(new ModPlusConnector());
#endif
            RevitEvent    = new RevitEvent();
            UiApplication = commandData.Application;

            if (commandData.View is ViewSchedule)
            {
                var el = new FilteredElementCollector(commandData.View.Document, commandData.View.Id)
                         .WhereElementIsNotElementType()
                         .Where(e => e.IsValidObject);
                if (!el.Any())
                {
                    MessageBox.Show(Language.GetItem("m2"));
                    return(Result.Cancelled);
                }

                var win     = new View.InScheduleWindow();
                var context = new InScheduleContext(win, commandData.Application);
                win.DataContext      = context;
                win.ContentRendered += (sender, args) => context.Initialize();
                ModPlus.ShowModal(win);
            }
            else
            {
                var selection           = commandData.Application.ActiveUIDocument.Selection;
                var doc                 = commandData.Application.ActiveUIDocument.Document;
                var preSelectedElements = selection.GetElementIds().Select(id => doc.GetElement(id)).ToList();
                var win                 = new View.InViewWindow();
                var context             = new InViewContext(win, commandData.Application);
                win.DataContext      = context;
                win.ContentRendered += (sender, args) => context.Initialize(preSelectedElements);
                ModPlus.ShowModeless(win);
            }

            return(Result.Succeeded);
        }
Example #4
0
 /// <summary>
 /// Private constructor. Initialize _rEvent object
 /// </summary>
 private DbObjectSet()
 {
     _rEvent = new RevitEvent();
 }