How to create variables

Objective:

Learn what a variable is and how to:

  • Create a block variable
  • Create a parameter variable
  • Use the info panel to create variables
  • Remove the contents of a variable

Answer:

A variable can be any block or parameter in the Notebook. By declaring a block as a variable, entire parts can be changed quickly and parametrically. An entire Notebook of functions can automatically be computed and rebuilt by simply changing values in the variable. Variables also allow for quick and easy organization and understanding of your Notebook since the variable blocks don't get nested within another block. 

To create a Block variable:

    • Select the block
    • R-click along the top of the block
    • Select "Make Variable"

A block variable looks different from a regular block. The name moves to the left and is on top of the block color (related to the block type). A block variable never "nests" inside another block. Instead, a "chip" is created to show that the variable is inserted in that block. Watch this quick gif below to see how to create a variable, re-name it, and insert it into another block.

             CreateVariable.gif

To create a Parameter variable:

    • R-click over the parameter name
    • Select "Make Variable"

 A parameter variable is a useful way to quickly change a specific aspect of a block. It makes it clear what input can change. See the gif below on how a parameter variable is made.

Parameter_Variable.gif

Use the Info Panel to Create Variables:

    • Expand the (?) symbol on the block to open the Info Panel
    • Go to the Properties Tab
    • Drag any property into the Notebook to create a variable of that property (these properties will be linked to the block they came from)

Propveri.gif

Removing Variable Contents:

    • Empty a variable by R-clicking on the variable and selecting "Remove Contents"

Emptying a variable allows the user to quickly change the contents of that variable while keeping the variable chip inserted as inputs in other blocks. Changing the Sphere and Cube to variables as well allows you to quickly replace them without having to R-click and remove contents. 

Note: In this example, the contents of a Cube block variable are being removed. In order to allow any Implicit Body input, the variable block icon needs to change from Cube to Implicit Body. To do this, click on the icon and either search the list or type in the desired input type. 

removevari.gif

More on this topic:

Keywords:

 block variable create parameter edit what is change using info vary creating removing variables make input chip nest 
Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.