Hi, i use rhinoinside unity example to create this code but when Grasshopper launched nothing received .
using Rhino.Runtime.InProcess;
using System;
namespace AnsysConnect
{
public class RhinoInside
{
static IDisposable _rhinoCore;
public static void Launch()
{
if (_rhinoCore == null)
{
string rhinoSystemDir = (string)Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\McNeel\Rhinoceros\7.0\Install",
"Path",
System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Rhino 7", "System")
);
if (!Environment.GetEnvironmentVariable("PATH").Contains(rhinoSystemDir))
{
var PATH = Environment.GetEnvironmentVariable("PATH");
Environment.SetEnvironmentVariable("PATH", PATH + ";" + rhinoSystemDir);
IntPtr hParent = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
//_rhinoCore = new RhinoCore(new string[] { "/scheme=Unity", "/nosplash" }, WindowStyle.Minimized, hParent);
_rhinoCore = new RhinoCore(new string[] { "/nosplash" }, WindowStyle.Minimized, hParent);
}
}
}
}
}
using AnsysConnectAddIn.Properties;
using SpaceClaim.Api.V19;
using SpaceClaim.Api.V19.Extensibility;
using System.Drawing;
namespace AnsysConnect
{
// Singleton version
class ConnectRhino : CommandCapsule
{
..........................
..........................
..........................
protected override void OnExecute(Command command, ExecutionContext context, Rectangle buttonRect)
{
Window window = Window.ActiveWindow;
window.InteractionMode = InteractionMode.Solid;
ShowGrasshopperWindow();
}
// CODE TO LAUNCH GRASSHOPPER
static bool _firstRun = true;
public static void ShowGrasshopperWindow()
{
string script = "!_-Grasshopper _W _T ENTER";
if (_firstRun)
{
_firstRun = false;
RhinoInside.Launch();
}
Rhino.RhinoApp.RunScript(script, false);
}
}
}
..........................
..........................
..........................
// DATA TO SEND
public void CurrentTime()
{
double time = Math.Round(Solver.CurrentTime, 3);
string currenttime = time.ToString();
using (var args = new Rhino.Runtime.NamedParametersEventArgs())
{
args.Set("current_time", currenttime);
Rhino.Runtime.HostUtils.ExecuteNamedCallback("CurrentTime", args);
}
}