Esempio n. 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);
        }
Esempio n. 2
0
        /// <summary>
        /// 启动 Python
        /// </summary>
        /// <param name="buttonEvent"></param>
        /// <returns></returns>
        public static MenuBarManager.CallbackStatus StartIronPython(MenuButtonEvent buttonEvent)
        {
            Guid PluginId = new Guid("814d908a-e25c-493d-97e9-ee3861957f49");

            if (!PlugIn.LoadPlugIn(PluginId, true, true))
            {
                throw new Exception("Failed to startup IronPyhton");
            }

            Rhinoceros.RunScript("_EditPythonScript", activate: true);

            return(MenuBarManager.CallbackStatus.Continue);
        }
        public static MenuBarManager.CallbackStatus StartGrasshopper(MenuButtonEvent buttonEvent)
        {
            Logger.Info("Starting Grasshopper");

            Thread.CurrentThread.CurrentCulture   = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

            Rhinoceros.RunScript("_Grasshopper", activate: true);

            //Instances.DocumentEditor?.GetHashCode().ToString().ConsoleWriteLine();

            //Guest.ShowEditor();

            Rhinoceros.MainWindow.BringToFront();

            Logger.Info("Start Grasshopper Succesfully.");

            return(MenuBarManager.CallbackStatus.Continue);
        }
Esempio n. 4
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);
        }