How can I attribute a parameter to multiple objects?

I would like to apply a custom parameter to a selection of objects with the following setup:

class MyPanel(bpy.types.Panel):
bl_label = "Tool"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"

@classmethod
def poll(cls, context):
return len(context.selected_objects) > 0

def draw(self, context):
layout = self.layout

myprop = context.active_object.myprop
row = layout.row()
row.prop(myprop, 'subdivs')


For now it works with the active_object, but how do I have to change my panel so it can pass on multiple variables to my update function?

• "how do I have to change my panel so it can pass on multiple variables to my update function ?" What is the update function supposed to be. This question is unclear. Feb 18 '14 at 17:14

bpy.props allows you to define your own get/set/update methods for a property.

import bpy

def update(self, context):
#self ~ owner of the property
for obj in context.selected_objects:
#assigning a value to obj.property would cause a recursion!!!
obj["custom_property"] = self.custom_property

bpy.types.Object.custom_property = bpy.props.IntProperty(update=update)


If you change the attribute custom_property for an object the change will be applied to all selected objects.

You can also use drivers to synchronize properties.