Example #1
0
        public WorksheetSelectForm(List <WorksheetObject> objs, ManageExcelLinksForm parent, Autodesk.Revit.DB.Document doc)
        {
            _objs      = objs;
            formParent = parent;
            _doc       = doc;
            InitializeComponent();

            int counter = 0;

            foreach (WorksheetObject wo in _objs)
            {
                if (wo.Image == null)
                {
                    counter++;
                }
            }

            if (counter == _objs.Count)
            {
                this.Height             = 160;
                previewImage.Visibility = System.Windows.Visibility.Hidden;
            }
            linkCheckBox.IsChecked       = true;
            linkCheckBox.IsEnabled       = false;
            wsComboBox.ItemsSource       = _objs;
            wsComboBox.DisplayMemberPath = "Name";
            wsComboBox.SelectedIndex     = 0;
        }
Example #2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                int version = Convert.ToInt32(commandData.Application.Application.VersionNumber);
                // Construct the form
                ManageExcelLinksForm form = new ManageExcelLinksForm(commandData.Application.ActiveUIDocument.Document, schemaGUID);

                // Get the Revit window handle
                IntPtr handle = IntPtr.Zero;
                if (version < 2019)
                {
                    handle = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
                }
                else
                {
                    handle = commandData.Application.GetType().GetProperty("MainWindowHandle") != null
                        ? (IntPtr)commandData.Application.GetType().GetProperty("MainWindowHandle").GetValue(commandData.Application)
                        : IntPtr.Zero;
                }
                System.Windows.Interop.WindowInteropHelper wih = new System.Windows.Interop.WindowInteropHelper(form)
                {
                    Owner = handle
                };

                // Show the form
                form.ShowDialog();

                // Write to home
                RevitCommon.FileUtils.WriteToHome("Excel Import - Manage Links", commandData.Application.Application.VersionName, commandData.Application.Application.Username);

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