algorithmic modeling for Rhino
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
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by