properties update ?

update function

“It can be useful to perform an action when a property is changed and can be used to update other properties or synchronize with external data.”

is there an example using this feature for a simple panel ?

or is it only for BGE may be?

thanks

don’t see any properties in that script i’m not talking about update for mesh here

more propertie floating update attribute

thanks

The properties are defined in the class.


############################################################################
# Parameter Definitiions
############################################################################
def updateFracTreeParameter(self,context):
    # This def gets called when one of the tagged properties, in the class below, changes state.
    global isBusy
        
    if isBusy == False:
        if context != None:
            passedScene = context.scene
            cf = passedScene.frame_current
            print("updateFractal TreeParameter on frame #" + str(cf))
            reviewFracTree (cf,passedScene)
            
class cls_FracTreeParms(bpy.types.PropertyGroup):
    '''
    n       = 7    
    l       = 4*5    # Branch Length    
    b       = 3    # Fork Size
    phi     = pi/3 * 0.6180469# Turn around branch direction
    l_f     = 0.6180469 # Scaling factor branch length reciprocal value of golden cut
    b_f     = 0.6180469 # Scaling factor fork size
    phi_f   = 1.0 # Scaling factor turn
    '''
    recursion_count = bpy.props.IntProperty(name="Recursion Count", description="Recursion Count.", default = 7, min = 0, max = 100, update=updateFracTreeParameter)
    branch_length = bpy.props.FloatProperty(name="Branch Length", description="Branch Length.", default=20.0, min = 0.1, max = 100.0, update=updateFracTreeParameter)
    fork_size = bpy.props.FloatProperty(name="Fork Size", description="Fork Size.", default=3.0, min = 0.1, max = 20.0, update=updateFracTreeParameter)
    branch_direction = bpy.props.FloatProperty(name="Branch Direction", description="Turn around branch direction.", default=0.6180469, min = -10.0, max = 10.0, update=updateFracTreeParameter)
    scale_branch = bpy.props.FloatProperty(name="Scale Branch", description="Scaling factor branch length reciprocal value of golden cut.", default=0.6180469, min = -10.0, max = 10.0, update=updateFracTreeParameter)
    scale_fork = bpy.props.FloatProperty(name="Scale Fork", description="Scaling factor fork size.", default=0.6180469, min = -10.0, max = 10.0, update=updateFracTreeParameter)
    scale_turn = bpy.props.FloatProperty(name="Scale Turn", description="Scaling factor turn.", default=1.0, min = -10.0, max = 10.0, update=updateFracTreeParameter)


Notice all the update=updateFracTreeParameter at the end of the bpy.props declaration? When a property changes in the panel, that def is executed.

sorry was not looking for group properties in script more like scene properties !

but is this available only inside defined class group for properties?

or can it be also use in a normally defined propreties

and is this feature transfered to a scene propertie fof instance or only for operator properties ?

EX:

bpy.types.Scene.skydomeradius = FloatProperty( # Myfloat is the name of the Float variable = Scene property
name=“Sky Dome Radius”, # Name printed in button
description=“Enter Sky Dome Radius”, # Tip tool
default = 12.0,
min = 0.0,
max = 100)

also with this feature you cannot redefine the parameters of the properties itself
like low high limit for values or other

just that if propertie change it can also execute a function or called an operator if inside a panel class

i have not seen this feature use often up to now
might be a new feature for propertie!

thanks

It seems like it works for scenes…

http://www.blender.org/documentation/blender_python_api_2_64_1/bpy.props.html?highlight=floatproperty#bpy.props.FloatProperty

seems it can work without group

tried to change a lamp color here but cannot be done in panel
don’t know is there a way to do it may be inside an operator or otherwise?

proppanel1.blend (402 KB)

thanks

Yeah, I have said before and I’ll say it again.

The tools panel is not worth programming.

You are better off just creating a specially named Empty and attaching your properties to that object. Then you can run code when the properties change and even animate the properties. With the tools panel, you can not.

don’t use that one very often
prefer the other using the Add mesh menu at least you can do things with that one!

thanks