// Use this for initialization void Start() { ResolveEventHandler OnRhinoCommonResolve = null; AppDomain.CurrentDomain.AssemblyResolve += OnRhinoCommonResolve = (sender, args) => { const string rhinoCommonAssemblyName = "RhinoCommon"; var assemblyName = new AssemblyName(args.Name).Name; if (assemblyName != rhinoCommonAssemblyName) { return(null); } AppDomain.CurrentDomain.AssemblyResolve -= OnRhinoCommonResolve; string rhinoSystemDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Rhino WIP", "System"); return(Assembly.LoadFrom(Path.Combine(rhinoSystemDir, rhinoCommonAssemblyName + ".dll"))); }; //rhinoCore = new RhinoCore(new string[] { $"/scheme=UNITY", "/nosplash", "/runscript=\"_Grasshopper\"" }, WindowStyle.Normal); rhinoCore = new RhinoCore(new string[] { $"/scheme=UNITY", "/nosplash" }, WindowStyle.Normal); doc = Rhino.RhinoDoc.ActiveDoc; SceneToRhino(); }
//The Startup event is raised after the VSTO Add-in is loaded //and all the initialization code in the assembly has been run. private void ThisAddIn_Startup(object sender, System.EventArgs e) { // Load Rhino try { //TODO >> grab Excel product name for scheme var scheme_name = "RhinoInsideExcel"; //Run Rhino.Inside no UI m_rhino_core = new Rhino.Runtime.InProcess.RhinoCore(new[] { $"/scheme={scheme_name}" }); //TODO >> Run Rhino.Inside with UI - Error -200 //m_rhino_core = new Rhino.Runtime.InProcess.RhinoCore(new[] { $"/scheme={scheme_name}" }, WindowStyle.Maximized); } catch (Exception ex) { //System.Windows.Forms.MessageBox.Show(ex.Message); System.Windows.Forms.MessageBox.Show("Cannot load Rhino Inside Addin"); } }
protected override void OnHandleDestroyed(EventArgs e) { rhinoCore.Dispose(); rhinoCore = null; base.OnHandleDestroyed(e); }
protected override void OnHandleCreated(EventArgs e) { rhinoCore = new Rhino.Runtime.InProcess.RhinoCore(new string[] { "/NOSPLASH" }, WindowStyle.Hidden, Handle); base.OnHandleCreated(e); }