I have a PropertyGroup Class called PPP, like the Collection Example on this page: http://www.blender.org/documentation/blender_python_api_2_63_release/bpy.props.html

The problem is that one of the properties in the PPP class, pfloat calls an update function "update_func"

I need to be able to tell which ppp has been changed when the update_func is called, normally you would use self to determine it but that does not seem to work it just returns: PPP("")

Any Ideas / what am I doing wrong?

closed as off-topic by CoDEmanX, David, gandalf3, Polosson, stacker Oct 23 '14 at 22:12

  • This question does not appear to be about Blender within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    Described behavior couldn't confirmed, see T39798. – CoDEmanX Oct 23 '14 at 20:24

I can't tell whether it's a known limitation or bug, but it definately returns the reference to the CollectionProperty only.

You need a concept of one element in the collection being "active", e.g. have an IntProperty alongside and use it for a template_list() for instance. Then use that number to get the right item:

self[context.scene.ppp_index].pfloat = 1.23

There's actually a reference to the CollectionProperty item returned,
see https://developer.blender.org/T39798

  • Thank you for the help. I have experimented with using Lambda it create the update_func If i can get that to work I might post it as an answer. Otherwise I will mark this as correct if I get no better answers or make no progress. – MCHammond Apr 19 '14 at 18:38
  • You should contact the python module owners and ask if a property callback in a collection is supposed to get the collection or the property passed, maybe no one thought of it? – CoDEmanX Apr 19 '14 at 20:32
  • Posted bug report and waiting for developer feedback: developer.blender.org/T39798 – CoDEmanX Apr 19 '14 at 20:38
  • Awesome, thank you. I am not very good with python/Blender. I was not comfortable with giving enough information about the problem. – MCHammond Apr 20 '14 at 1:43
up vote 0 down vote accepted

I have a solution to this problem using Python Lambda.

Create an an update function called "updateID" with inputs for Self,Context and ID

then when creating your property do this:

update = eval("lambda s,c: updateID(s,c,\"%s\")" %foo)

foo is the unique ID that you use to identify that object inside the updateID function like the properties name.

This will create a unique update function for each instance of the property that simply calls the "updateID" function and plums in the ID variable.

  • 1
    I'm certain you could drop the eval in the code i.e. update = lambda s,c: updateID(s,c,"{0}".format(foo)) or update = lambda s,c: updateID(s,c,foo) – Carel Sep 2 '16 at 4:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.