Fologram for Grasshopper contains components for getting and setting static variables that can be accessed from anywhere in your grasshopper document. These global variables are useful for storing references to objects that are changed over time (such as building applications where a user might want to select and then move control points on a curve), for building counters (where a user may wish to increment a value whenever they click on a button), or building simple iterative loops without needing to resort to writing code (where a user may wish to edit an object or geometry with a repeating procedure).
Creating and Assigning Global Variables
Global variables are created with the Set Global Variables component. Renaming the component will assign a name to the variable. Inputting any data to the component will update the stored data of the global variable.
You can access a global variable with the Get Global Variable component and assigning it the name of the variable you wish to access. The Get Global Variable component will automatically update to the latest stored value whenever a component connected downstream updates. E.g. in the example above, changing the value of B will update the addition component, which will then 'pull' the latest value of myNumber. By default, changing the value of myNumber elsewhere in your definition will not trigger downstream changes Get Global components. E.g. if we were to change the value of myNumber, the addition component in the example above would not update.
Getting Live Values
You can use the Live Update mode of the Get Global Variables component to trigger downstream changes when you update the value of a global variable elsewhere in your definition. When Live Update is turned on (by right clicking on the left hand side of the Get Global Variables component and toggling the Live Update option), the component will listen for changes made to the variable from anywhere in your definition and update when they are detected. E.g. in the example above, changing the value of myNumber with Live Update turned on would update the addition component.
Note: Beware of creating infinite loops using Live Update!