I'm trying to make all the selected objects take the value "True-False" simply from a Boolean checkbox, I can't find a correct way, only the active object takes the value, I would like that the other selected ones also take on the same . This is an example:

import bpy
from bpy.utils import register_class, unregister_class
from bpy.props import BoolProperty
from bpy.types import Object, Panel,PropertyGroup

class MyPanel(Panel):

    bl_label = "Checkbox Test"
    bl_idname = "TEST_PT_Panel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "Test"

    def draw(self, context):

        ob = bpy.context.active_object                    
        layout = self.layout                       
        row = layout.split()    

        row.prop(ob.object_prop,"bool_prop", text = 'Object Bool Prop')

def updatebool(self,context):

    ###in that update function i try to make the boolprop attribute on multiple selected objects:

    selected = bpy.context.selected_objects
    active = bpy.context.active_objects

    for o in selected:
        if o.type == 'MESH':

            ### this is my problem:
            o.object_prop.bool_prop = active.object_prop.bool_prop

class OBJECT_Prop(PropertyGroup): 

    bool_prop: BoolProperty(default= False, update=updatebool) 

classes = (MyPanel,OBJECT_Prop)

def register():

    for cls in classes:       

    Object.object_prop = bpy.props.PointerProperty(type=OBJECT_Prop)

def unregister():

    for cls in reversed(classes):       

if __name__ == "__main__":
  • $\begingroup$ It's seems a bit weird to me: you are putting an update function on an object that affects other objects which have an update function of their own. Have you considered placing the bool with the update funtion on a panel instead of an object? If not, in your for loop try to make the "o" object the active object, maybe it solves it $\endgroup$ – Tareyes Aug 28 '19 at 12:45

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.