algorithmic modeling for Rhino
Hi all,
I need to save some data (string) into the grasshopper file so that is visible to all components.
With the snipped below I save custom data for each individual component. How would I go about saving the "someStringToSave" so that it is written only once into the archive and visible to all component on the canvas.
Thanks a bunch in advance.
T
public override bool Write(GH_IO.Serialization.GH_IWriter writer)
{
writer.SetString("settings", someStringToSave );
return base.Write(writer);
}
public override bool Read(GH_IO.Serialization.GH_IReader reader)
{
string savedString= reader.GetString("settings");
}
Tags:
Hi David, I have been using this approach quite successfully. However, now I have an issue with clusters. Components within a cluster cannot find the material library outside. Any advice on that?
I am using the following code to search the lib component:
var doc = OnPingDocument(); // to get the document
foreach (IGH_DocumentObject docObject in doc.Objects)
{
//comparing guids in here to find the right component
}
Yep, if you're inside a cluster then you also need to look in the parent document. I attached a file which uses a C# component which figures out whether it's inside a cluster or not.
Of course remember that clusters may be nested, so you need to keep looking at the Owner of each document until that owner is null or until you find your materials.
Also note that in my scheme I do not expire components inside clusters if the material libraries change.
David here demonstrates why all the good stuff, all the creative energy in Rhino is now firmly entrenched in Grasshopper and this very forum rather than just the old school "macro" world of normal script editors in the Rhino program.
It helps that this forum has better formatting than http://discourse.mcneel.com so is nicer to look at, having threading and all, and a gallery.
David is basically the Army Corps of Engineers.
Even in normal Rhino script editing, Python, despite IronPython hassles, Grasshopper "node-in-code" calls now amount to a serious script library optimized for Rhino.
I just had to learn to spurn Rhinoscript in favor of Rhinocommon, and then it all made sense.
I actually much prefer the discourse forum, but then a significant part of my day is spend nursing this forum (approving new members, hunting for spammers, removing bogus content) which just annoys me.
But enjoy it while you can here, I suppose at some point we'll switch over to discourse.
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
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by