Page MenuHome

custom property (listed in sub-classed panel) does not update driver's variable
Closed, InvalidPublic

Description

I noticed that a custom property of an object that is listed in a sub-classed panel (say, "My Own Panel" for an object) does not propagate its value to a driver's variable. However, the Custom Property panel's entry of the same custom property DOES propagate its value correctly to the driver's variable.

Example script: Run the script and go to Cube object's object panel. Change the property camXLocation value both in the Custom Property panel.. and in the "My Settings" panel. The Custom Properties prop changes translate the camera, the My Settings prop changes doesn't.

import bpy
import mathutils
from math import *
from bpy.props import *


# link the cube's property to camera X location
def setupDriver():
camera = bpy.data.objects['Camera']
cube = bpy.data.objects['Cube']

# define and set custom property for cube object
cube.FloatProperty(attr="camXLocation", default = 10.0, min = 0, max = 50)
cube.camXLocation = 10.0

# create a driver for camera x location (scripted)
driver = camera.driver_add("location", 0).driver
driver.type = "SCRIPTED"
driver.expression = "x"

# create a variable for the driver
var = driver.variables.new()
var.name = "x"

# link variable to cube object's camXLocation property
targ = var.targets[0]
targ.id_type = "OBJECT"
targ.id = cube
targ.data_path = 'camXLocation'
# I also tried targ.data_path = '["camXLocation"]'

# object panel to display camXLocation property
class OBJECT_PT_my_settings(bpy.types.Panel):
'''My Settings Panel'''
bl_label = "My Settings"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"

# draw the gui
def draw(self, context):
layout = self.layout

ob = context.active_object

if ob and ob.name == "Cube":
# some property
row = layout.row()
row.prop(ob, "camXLocation", text="Camera X Location")


def register():
bpy.types.register(OBJECT_PT_my_settings)


def unregister():
bpy.types.unregister(OBJECT_PT_my_settings)


if __name__ == "__main__":
register()
setupDriver()

Details

Type
Bug

Event Timeline

This is something for todo. Dependency graph needs to be redesigned for this. Moving to todo wiki: http://wiki.blender.org/index.php/Dev:2.5/Source/Development/Todo/UserInterface#Dependency_Graph