generative modeling for Rhino
Guys,
I need to control some parameters in Grasshopper from an external tool, so I need to know how to make a batch file for the grasshopper? Does anyone know?
I do really have problem in my research. Any help would be appreciated a lot.
Thanks,
M
Permalink Reply by YANG on June 3, 2011 at 2:46am
Permalink Reply by michael sprinzl on June 3, 2011 at 6:10am private void fire_grasshopper(string Address, Boolean reading_from_file)
{
string text_in;
//read data
if (reading_from_file)
{
text_in = read_file();
}
else
{ text_in = Address; }
//open grasshopper
Grasshopper.Plugin.GH_RhinoScriptInterface obj = Rhino.RhinoApp.GetPlugInObject("Grasshopper") as Grasshopper.Plugin.GH_RhinoScriptInterface;
obj.DisableBanner();
obj.CloseAllDocuments();
obj.HideEditor();
obj.DisableSolver();
obj.OpenDocument(text_in);
obj.EnableSolver();
find_definition_grasshopper();
execute_grasshopper();
obj.CloseAllDocuments();
}
private void execute_grasshopper()
{
Grasshopper.Kernel.GH_DocumentServer docServer = Grasshopper.GH_InstanceServer.DocumentServer;
Grasshopper.Kernel.GH_Document doc_grass = docServer[0];
Grasshopper.Kernel.IGH_DocumentObject grass_node = find_node(doc_grass, "bake");
if (grass_node != null)
{
Grasshopper.Kernel.Parameters.Param_GenericObject param_generic;
try
{
param_generic = (Grasshopper.Kernel.Parameters.Param_GenericObject)grass_node;
param_generic.CollectData();
if (param_generic.IsBakeCapable == true)
{
param_generic.BakeGeometry(doctoplevel, new List<Guid>());
}
}
catch (System.InvalidCastException)
{
Rhino.UI.Dialogs.ShowMessageBox("please use generic data primitive", "ERROR");
}
finally { }
}
this is an example how to call grasshopper and bake a component
Permalink Reply by M NICK on June 20, 2011 at 4:44pm
Permalink Reply by michael sprinzl on June 21, 2011 at 12:16am Added by David Stasiuk 7 Comments 21 Likes
Added by stefano 5 Comments 7 Likes
© 2013 Created by Scott Davidson.
Powered by