Setting a slider value from within the code

07-16-2013 11:35 PM
New Contributor II
I would like to set the slider value from within the code but then still be able to modify the slider/attribute value manualy affterwards?

Lets say that i have a generic rule which defines several building typologyes. If every typology has a different number of floors i would normaly set the "number_of_floors" attribute within the typology definition to a certain valuey using "set" comand and then extrude.

attr number_of_floors  = 0

Building_type_1 -->

set(number_of_floors, 5)
extrude (floor_height*number_of_floors)

Building_type_2 -->

set(number_of_floors, 3)
extrude (floor_height*number_of_floors)

This should be just a starting point, showing the defalut settup (default number of floors/height) which you should be able to manually edit using parameters afterwards. But in this case the "number_of_floors" attribute gets assigned a certain value within the code and is not possible to edit it with the slider anymore, ie. the modifying the slider values dont affect the model generation anymore. Is there a way just the set, lets say "user" attribute value and not "rule" value?
Tags (2)
0 Kudos
2 Replies
Frequent Contributor
Hi ..

CGA can not dictate the attribute source. CGA gets the attribute values to work with.

the Connection Editor dictates, which value is used. There's just the 4 states 'Rule', 'User', 'Object Attr' [[or 'Mapped']].

So in your case, I'd create a second attribute which dictates the source for your attribute of interest.


@Hidden // = generic attribute to transport the info
attr finalValue = 0

@Range ( "Rule", "User", "Object" )
attr useWhichAttr = "Rule"

attr ruleDefaultValue = rand(10,20) // connection : attr source = "rule"

attr userValue = rand(10,20)         // connection : attr source = "user" // = you playing with slider

attr objectAttrValue = 0         // value initialized with 0  // connection : attr source = "object" 

Then :

Lot -->
    case useWhichAttr == "Rule" :
        set(finalValue, ruleDefaultValue )
    case useWhichAttr == "User" :
        set(finalValue, userValue ) 
    else :
        set(finalValue, objectAttrValue )

GoExtrude -->
    extrude( finalValue )

Like this, you control all possibilities.

Ok ?

0 Kudos
New Contributor II
Good to know. Thanks.
0 Kudos