algorithmic modeling for Rhino
This code is a bit sloppy, but it will save a state for ALL "state aware" objects. You could set it up to be more selective about which objects to save the state for. Also notice this does not include any cleanup code to support overwriting existing states - it is possible with this code to wind up with a bunch of states with identical names.
GH_State state = new GH_State();
foreach(IGH_DocumentObject obj in GrasshopperDocument.Objects){
if(obj is IGH_StateAwareObject){
IGH_StateAwareObject SAO = (IGH_StateAwareObject) obj;
state.AddStateObject(SAO, obj.InstanceGuid);
}
}
state.Name = "Name of State";
GrasshopperDocument.StateServer.Add(state);
I got to the GH_State method but didn't understand in args for it. I'll give this a go. Thanks for this starter.
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