There's a piece I'm missing on how the PropertyGroup works. I thought that assigning each to an object would hold the data and be available for manipulation later. However the display through the panel always shows the active object (at least the way I have it set up).

Here is an example and the code:

enter image description here

import bpy

def resize(self, context):
    o = bpy.context.object
    o.dimensions.x = o.my_settings.length

class MySettings(bpy.types.PropertyGroup):
    reverse : bpy.props.BoolProperty(name = "Direction", description = "Direction",default = False )
    length : bpy.props.FloatProperty(name = "Length", description = "Wall Length", default = 12.0, update = resize)

class TEST_PT_Panel(bpy.types.Panel):
    bl_idname = "TEST_PT_Panel"
    bl_label = "Test Panel"
    bl_category = "Test Addon"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"

    def draw(self, context):
        layout = self.layout
        scene = context.scene
        obj = context.object

        box = layout.box()

        for ob in bpy.data.objects:
            row = box.row()
            row.label(text = "Object: " + ob.name)

            row = box.row()
            row.prop(obj.my_settings, "reverse")

            row = box.row()
            row.prop(obj.my_settings, "length")

classes = (

def register():
    from bpy.utils import register_class
    for cls in classes:
    bpy.types.Object.my_settings = bpy.props.PointerProperty(type=MySettings)

def unregister():
    from bpy.utils import unregister_class
    for cls in reversed(classes):

if __name__ == "__main__":

I thought each object would get a copy of MySettings PropertyGroup and that when looping through each object would reference them. However in the example the operator works only on the active object, while the panel seems to only be aware of one instance of the PropertyGroup.

What I'm trying to accomplish is having each 'Length' update the object it references in the panel. At this point not sure if I haven't assigned them correctly somehow, or not using them correctly.

  • 2
    $\begingroup$ You have assigned active object as obj and when you loop over the objects, each is assigned as ob. Use ob in the layout props and it wont always be context object. btw would be far better off to loop over context.scene.objects rather than all objects in file which may not be linked to scene. In the resize method o = self.id_data otherwise this will always use context object too. $\endgroup$
    – batFINGER
    Aug 9 '19 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.