Grasshopper

algorithmic modeling for Rhino

how to access an Grasshopper.Kernel.IGH_DocumentObject to bake it in c#

hello,

i am working on a plugin which needs access to grasshopper. everything works well on the document and server level. But i cannot find any method to access the geometry data within Grasshopper.Kernel.IGH_DocumentObject to bake the data.

 

with best regards

Michael Sprinzl

 

 

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");

 

private Grasshopper.Kernel.IGH_DocumentObject find_node(Grasshopper.Kernel.GH_Document grasshopper_document,string pathname)
        {
Grasshopper.Kernel.IGH_DocumentObject grass_node = grasshopper_document.Objects[0];
           

 for (int i = 0; i < grasshopper_document.Objects.Count; i++)
            {
                if (grasshopper_document.Objects[i].Attributes.PathName == pathname)
                {
                    grass_node = grasshopper_document.Objects[i];
                }
            }


            if (pathname != grass_node.Attributes.PathName)

{ return null; }

else

{return grass_node;}
        }

Views: 466

Replies to This Discussion

Hi Michael,

 

that's because not all IGH_DocumentObjects have geometry to Bake. Scribbles and Text Panelsdon't, neither do Slider and Colour Swatches.

 

All objects that have Geometry will implement the Kernel.IGH_BakeAwareObject interface. So you'll first need to check whether an object implements that interface and then you can cast it and call the BakeGeometry method.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

thanks david worked very well... I have some plugin attached to show the raw way what I want to achieve. So copy the folder somewhere and then install the plugin... It is still very buggy.

use the shiva_config command and set to the bake plugin. cancel then ...  then use the shiva_fire command

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service