Example #1
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            //always initialize RevitTask in Revit API context before calling any RunAsync method
            RevitTask.Initialize();
            //Register your own global generic external event handler
            RevitTask.RegisterGlobal(new GetRandomFamilyExternalEventHandler());
            var window = new TestWindow();

            window.Show();
            return(Result.Succeeded);
        }
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            var process = Process.GetCurrentProcess();
            var winname = typeof(MainWindow).Namespace + "." + nameof(MainWindow);

            if (WindowAlreadyExist(process, winname))
            {
                Message.Display("Main window already exist", WindowType.Information);
                return(Result.Failed);
            }

            RevitTask.Initialize();

            var mainWindow = new MainWindow(commandData.Application.ActiveUIDocument.Document);

            mainWindow.Closed += (s, e) => Utility.Properties.Settings.Default.Save();

            new WindowInteropHelper(mainWindow)
            {
                Owner = process.MainWindowHandle
            };

            if (!mainWindow.IsVisible)
            {
                mainWindow.Show();
            }
            if (mainWindow.WindowState == WindowState.Minimized)
            {
                mainWindow.WindowState = WindowState.Normal;
            }

            mainWindow.Activate();
            mainWindow.Topmost = true;
            mainWindow.Topmost = false;
            mainWindow.Focus();

            return(Result.Succeeded);
        }
Example #3
0
        public Result OnStartup(UIControlledApplication application)
        {
            //Always initialize RevitTask ahead of time within Revit API context
            RevitTask.Initialize();

            UICtrlApp = application;
            // Fires an init event, where we can get the UIApp
            UICtrlApp.Idling += Initialise;

            var    specklePanel  = application.CreateRibbonPanel("Speckle 2");
            var    speckleButton = specklePanel.AddItem(new PushButtonData("Speckle 2", "Revit Connector", typeof(App).Assembly.Location, typeof(SpeckleRevitCommand).FullName)) as PushButton;
            string path          = typeof(App).Assembly.Location;

            if (speckleButton != null)
            {
                speckleButton.Image                 = LoadPngImgSource("Speckle.ConnectorRevit.Assets.logo16.png", path);
                speckleButton.LargeImage            = LoadPngImgSource("Speckle.ConnectorRevit.Assets.logo32.png", path);
                speckleButton.ToolTip               = "Speckle Connector for Revit";
                speckleButton.AvailabilityClassName = typeof(CmdAvailabilityViews).FullName;
                speckleButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://speckle.systems"));
            }

            //desktopui 2
            var speckleButton2 = specklePanel.AddItem(new PushButtonData("Speckle 2 New Ui", "Revit Connector\nNew UI (alpha)!", typeof(App).Assembly.Location, typeof(SpeckleRevitCommand2).FullName)) as PushButton;

            if (speckleButton2 != null)
            {
                speckleButton2.Image                 = LoadPngImgSource("Speckle.ConnectorRevit.Assets.logo16.png", path);
                speckleButton2.LargeImage            = LoadPngImgSource("Speckle.ConnectorRevit.Assets.logo32.png", path);
                speckleButton2.ToolTip               = "Speckle Connector for Revit - With a new UI";
                speckleButton2.AvailabilityClassName = typeof(CmdAvailabilityViews).FullName;
                speckleButton2.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://speckle.systems"));
            }


            PulldownButton helpPulldown = specklePanel.AddItem(new PulldownButtonData("Help&Resources", "Help & Resources")) as PulldownButton;

            helpPulldown.Image      = LoadPngImgSource("Speckle.ConnectorRevit.Assets.help16.png", path);
            helpPulldown.LargeImage = LoadPngImgSource("Speckle.ConnectorRevit.Assets.help32.png", path);


            PushButton forum = helpPulldown.AddPushButton(new PushButtonData("forum", "Community Forum", typeof(App).Assembly.Location, typeof(ForumCommand).FullName)) as PushButton;

            forum.ToolTip    = "Check out our Community Forum! Opens a page in your web browser.";
            forum.Image      = LoadPngImgSource("Speckle.ConnectorRevit.Assets.forum16.png", path);
            forum.LargeImage = LoadPngImgSource("Speckle.ConnectorRevit.Assets.forum32.png", path);

            PushButton tutorials = helpPulldown.AddPushButton(new PushButtonData("tutorials", "Tutorials", typeof(App).Assembly.Location, typeof(TutorialsCommand).FullName)) as PushButton;

            tutorials.ToolTip    = "Check out our tutorials! Opens a page in your web browser.";
            tutorials.Image      = LoadPngImgSource("Speckle.ConnectorRevit.Assets.tutorials16.png", path);
            tutorials.LargeImage = LoadPngImgSource("Speckle.ConnectorRevit.Assets.tutorials32.png", path);

            PushButton docs = helpPulldown.AddPushButton(new PushButtonData("docs", "Docs", typeof(App).Assembly.Location, typeof(DocsCommand).FullName)) as PushButton;

            docs.ToolTip    = "Check out our documentation! Opens a page in your web browser.";
            docs.Image      = LoadPngImgSource("Speckle.ConnectorRevit.Assets.docs16.png", path);
            docs.LargeImage = LoadPngImgSource("Speckle.ConnectorRevit.Assets.docs32.png", path);

            PushButton manager = helpPulldown.AddPushButton(new PushButtonData("manager", "Manager", typeof(App).Assembly.Location, typeof(ManagerCommand).FullName)) as PushButton;

            manager.ToolTip    = "Manage accounts and connectors. Opens SpeckleManager.";
            manager.Image      = LoadPngImgSource("Speckle.ConnectorRevit.Assets.logo16.png", path);
            manager.LargeImage = LoadPngImgSource("Speckle.ConnectorRevit.Assets.logo32.png", path);



            return(Result.Succeeded);
        }