Пример #1
0
        public Autodesk.Revit.UI.Result OnStartup(UIControlledApplication applicationUI)
        {
            ApplicationUI = applicationUI;

#if REVIT_2019
            MainWindowHandle = ApplicationUI.MainWindowHandle;
#else
            MainWindowHandle = Process.GetCurrentProcess().MainWindowHandle;
#endif

            // Load Rhino
            try
            {
                var schemeName = ApplicationUI.ControlledApplication.VersionName.Replace(' ', '-');
                rhinoCore = new RhinoCore(new string[] { $"/scheme={schemeName}", "/nosplash" }, WindowStyle.Normal, MainWindowHandle);
            }
            catch (Exception e)
            {
                Debug.Fail(e.Source, e.Message);
                return(Autodesk.Revit.UI.Result.Failed);
            }

            // Register UI
            {
                RibbonPanel ribbonPanel = ApplicationUI.CreateRibbonPanel("Rhinoceros");

                Sample1.CreateUI(ribbonPanel);
                Sample4.CreateUI(ribbonPanel);
            }

            // Add an Idling event handler to notify Rhino when the process is idle
            ApplicationUI.Idling += new EventHandler <IdlingEventArgs>(OnIdle);

            return(Autodesk.Revit.UI.Result.Succeeded);
        }
Пример #2
0
        public Result OnStartup(UIControlledApplication applicationUI)
        {
            ApplicationUI = applicationUI;

#if REVIT_2019
            MainWindowHandle = ApplicationUI.MainWindowHandle;
#else
            MainWindowHandle = Process.GetCurrentProcess().MainWindowHandle;
#endif

            // Load Rhino
            try
            {
                var schemeName = ApplicationUI.ControlledApplication.VersionName.Replace(' ', '-');
                rhinoCore = new RhinoCore(new string[] { $"/scheme={schemeName}", "/nosplash" }, WindowStyle.Hidden, MainWindowHandle);
            }
            catch (Exception e)
            {
                Debug.Fail(e.Source, e.Message);
                return(Result.Failed);
            }

            // Reset document units
            UI.RhinoCommand.ResetDocumentUnits(Rhino.RhinoDoc.ActiveDoc);

            // Register UI on Revit
            {
                var ribbonPanel = ApplicationUI.CreateRibbonPanel("Rhinoceros");

                UI.RhinoCommand.CreateUI(ribbonPanel);
                UI.GrasshopperCommand.CreateUI(ribbonPanel);
                UI.PythonCommand.CreateUI(ribbonPanel);
                ribbonPanel.AddSeparator();
                Sample1.CreateUI(ribbonPanel);
                Sample4.CreateUI(ribbonPanel);
                Sample6.CreateUI(ribbonPanel);
                ribbonPanel.AddSeparator();
                UI.HelpCommand.CreateUI(ribbonPanel);
            }

            // Register some events
            ApplicationUI.Idling += OnIdle;
            ApplicationUI.ControlledApplication.DocumentChanged += OnDocumentChanged;

            // Register GrasshopperPreviewServer
            grasshopperPreviewServer = new GH.PreviewServer();
            grasshopperPreviewServer.Register();

            return(Result.Succeeded);
        }