custom property (listed in sub-classed panel) does not update driver's variable #23639

Closed
opened 2010-09-02 18:05:12 +02:00 by Dolphin Dream · 3 comments
Member

%%%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()

%%%

%%%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() ``` %%%
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Member

%%%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%%%

%%%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%%%
Member

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#23639
No description provided.