Triggering a Save State

Is it possible (VB, C, or Python) to call the command "Save State" from the Solution drop down menu while Galapagos is running?

  • up

    Andrew Heumann

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

    1