Hi to all,
Using Rhino 6, I need to launch the executable from an external C# App and then to call a specific Command that I developed as a plug-in. The command is already installed and works properly.
I want to know if and how this is possibile to do.
I can easly launch Rhino with simple C# lines but then if i try to use RhinoApp.RunScript() it gives me an error as he can’t see the Rhino Instance.
Actually I see that I lose the reference of the lanuched app, so here I ask you if there is a proper way to do it, if there are some settings that i need to implement to my C# App and so on.
Thank you to all!
La butto li, e se imposti che il comando viene eseguito automaticamente nelle impostazioni di Rhino?
Intendo quelle presenti nelle proprietà di Rhino->General->Run these commands every time Rhino starts
Ciao Lucio, per quanto sia corretta questa soluzione purtroppo non è ciò che mi serve.
Sono riuscito comunque a trovare quello che fa al caso mio:
public static dynamic LoadRhino()
{
// Try creating an instance of Rhino
dynamic rhino = null;
try
{
const string rhino_id = "Rhino.Application";
var type = Type.GetTypeFromProgID(rhino_id);
rhino = Activator.CreateInstance(type);
}
catch
{
// ignored
}
if (null == rhino)
{
Console.WriteLine("Failed to create Rhino application");
return null;
}
// Wait until Rhino is initialized before calling into it
const int bail_milliseconds = 15 * 1000;
var time_waiting = 0;
while (0 == rhino.IsInitialized())
{
Thread.Sleep(100);
time_waiting += 100;
if (time_waiting > bail_milliseconds)
{
Console.WriteLine("Rhino initialization failed");
return null;
}
}
return rhino;
}
Per poi chiamare fuori:
dynamic rhino = LoadRhino();
if (rhino == null)
return;
#if DEBUG
rhino.Visible = 1;
#else
rhino.Visible = 0;
#endif
rhino.RunScript("_-MyCommand", 0);
Grazie comunque dell’aiuto!
1 Mi Piace