Create a simple slider Rule
Compose a simple Rule: a slider that controls the trunk height of an existing tree model.
Note
To get proper and meaningful results from this example Rule, you need to use a tree with a first level branch generator named "Trunk" that can afford a height value between 20 and 80. For example, use the Conifer available in the Samples provided with the Modeler.
Create a slider
From the menu, select Window > Rules.
In the script editor of the Rules window, compose the following statement:
HeightValue = rule("Height", 45.0, 20.0, 80.0)
- Click anywhere outside the Rules window.
The UI section of the Rule window displays a slider named Height. The slider allows you to change the value of a variable named HeightValue
between 20
and 80
and the default value is 45
.
Make the slider control the trunk height
Select the Trunk generator of the tree.
In the Property Bar, select the Spine tab.
Under Spine > Length, right-click on the Absolute property and select Copy edit line for script.
Under the first statement you composed in the Rule editor, paste the copied information:
HeightValue = rule("Height", 45.0, 20.0, 80.0) set_property_value("=Trunk", "Spine:Length:Absolute", VALUE)
Update the
VALUE
parameter of theset_property_value
function to match the Rule's variable name (HeightValue
):HeightValue = rule("Height", 45.0, 20.0, 80.0) set_property_value("=Trunk", "Spine:Length:Absolute", HeightValue)
Click anywhere outside the Rules window.
When you adjust the slider, the trunk of the tree gets longer or shorter.