Canvas State Manager
Saves and restores the Enabled/Disabled (Locked) and Preview (Hidden) state of all components on the canvas.
Overview
Saves and restores the Enabled/Disabled (Locked) and Preview (Hidden) state of all components on the canvas.
Inputs (6)
- Save State (Boolean): Button to save current canvas state
- Save Name (Text): Name to save the state under
- Load State (Boolean): Button to load the specified canvas state
- Load Name (Text): Name of the state to load
- Turn Off New Nodes (Boolean): If true, new nodes added after the state was saved will have preview disabled (hidden).
- Import JSON (Text): Optional JSON string from another State Manager to merge states.
Outputs (3)
- Available States (Text): List of saved states
- Info (Text): Status output
- Export JSON (Text): Serialized JSON of all saved states. Plug this into 'Import JSON' of another State Manager to share states.
Method, assumptions and simplifications
The same notes appear in the component's Info output.
Method
- On a rising edge of Save, the Locked (disabled) and Hidden (preview off) flags of every other object on the canvas are stored under Save Name, keyed by object instance GUID.
- On a rising edge of Load, or when Load Name changes while Load is held true, a solution is scheduled that restores the stored flags. With Turn Off New Nodes, objects not in the stored state get their preview turned off (they are not disabled).
- States are saved inside the Grasshopper file and can be copied or pasted as JSON from the component menu; Export JSON outputs them. States can also be merged from another State Manager through the Import JSON input; they are merged when the input text changes, replacing states of the same name.
Assumptions
- Objects keep their instance GUIDs; copied or re-created components count as new nodes.
Simplifications and limits
- Only Locked and Hidden are stored; wires, values and positions are not.