Пример #1
0
        /// <summary>
        /// 将被启动器进行调用
        /// </summary>
        /// <returns></returns>
        public static int Register()
        {
            int retValue = 0;

            try
            {
                isDisposeCalled = false;

                theProgram = new NX();

                Logger.Info("Starting RhinoInside.");

                var result = Rhinoceros.RhinoStartup();

                if (result != MenuBarManager.CallbackStatus.Continue)
                {
                    "Can't Start Rhino Enviroment.".ShowInNXMessageBox(NXMessageBox.DialogType.Error);
                    Logger.Error("Can't Start Rhino Enviroment.");
                    return(0);
                }

                GrassHopperDefaultAssemblyFolder = Grasshopper.Folders.DefaultAssemblyFolder;

                File.Copy(Path.Combine(ApplicationPath, "RhinoInside.NX.GH.Loader.dll"), Path.Combine(GrassHopperDefaultAssemblyFolder, "RhinoInside.NX.GH.Loader.gha"), true);

#if DEBUG
                File.Copy(Path.Combine(ApplicationPath, "RhinoInside.NX.GH.Loader.pdb"), Path.Combine(GrassHopperDefaultAssemblyFolder, "RhinoInside.NX.GH.Loader.pdb"), true);
#endif

                theUI.MenuBarManager.AddMenuAction("STARTRHINO", new MenuBarManager.ActionCallback(RhinoCommands.StartRhino));
                theUI.MenuBarManager.AddMenuAction("IMPORTRHINO", new MenuBarManager.ActionCallback(ImportCommand.ImportRhino));

                theUI.MenuBarManager.AddMenuAction("STARTIRONPYTHON", new MenuBarManager.ActionCallback(RhinoCommands.StartIronPython));

                theUI.MenuBarManager.AddMenuAction("STARTGRASSHOPPER", new MenuBarManager.ActionCallback(GrasshopperCommands.StartGrasshopper));
                theUI.MenuBarManager.AddMenuAction("STARTGRASSHOPPERPLAYER", new MenuBarManager.ActionCallback(CommandGrasshopperPlayer.StartGrasshopperPlayer));
                theUI.MenuBarManager.AddMenuAction("GRASSHOPPERSOLVER", new MenuBarManager.ActionCallback(GrasshopperCommands.StartGrasshopper));
                theUI.MenuBarManager.AddMenuAction("GRASSHOPPERRECOMPUTE", new MenuBarManager.ActionCallback(GrasshopperCommands.GrasshopperRecompute));
                theUI.MenuBarManager.AddMenuAction("GRASSHOPPERBAKE", new MenuBarManager.ActionCallback(GrasshopperCommands.GrasshopperBake));

                theUI.MenuBarManager.AddMenuAction("RHINOINSIDEPREFERENCES", new MenuBarManager.ActionCallback(SetRhinoInsidePreferences));
                theUI.MenuBarManager.AddMenuAction("RHINOINSIDEINFORMATION", new MenuBarManager.ActionCallback(ShowRhinoInsideInformation));
                theUI.MenuBarManager.AddMenuAction("RHINOINSIDEHELP", new MenuBarManager.ActionCallback(ShowRhinoInsideHelp));

                MainWindow = new WindowHandle(NXOpenUI.FormUtilities.GetDefaultParentWindowHandle());

                Environment.SetEnvironmentVariable("RhinoInside_Program_Directory", RootPath);

                Logger.Info("Start RhinoInside Succesfully.");
            }
            catch (NXOpen.NXException ex)
            {
                ex.ToString().ShowInNXMessageBox(NXMessageBox.DialogType.Error);
                Logger.Error($"Start RhinoInside Failed. {ex}");
                retValue = 1;
            }
            return(retValue);
        }
Пример #2
0
        /// <summary>
        /// 用户关闭 Rhino 界面后,通过此按钮重新打开
        /// </summary>
        /// <param name="buttonEvent"></param>
        /// <returns></returns>
        public static MenuBarManager.CallbackStatus StartRhino(MenuButtonEvent buttonEvent)
        {
            if (Rhinoceros.Core == null)
            {
                Rhinoceros.RhinoStartup();
            }

            try
            {
                Rhinoceros.Exposed = true;
            }
            catch (Exception ex)
            {
                theUI.NXMessageBox.Show("Block Styler", 0, ex.ToString());
            }
            finally
            {
            }
            return(0);
        }