Is it possible to have individual operator properties for each selected object? I would like to change several things for each selected object. I don’t know if this is possible ,but haven’t found anything that works.
I have tried something like this. It was suppose to create a bool property for each selected name and if checked show object name.
class ScaleOp(bpy.types.Operator):
SEL_OBJS = bpy.context.selected_objects
for OBJECT_SETTINGS in SEL_OBJS:
OBJECT_SETTINGS: bpy.props.BoolProperty()
def draw(self, context):
layout = self.layout
col = layout.column()
SEL_OBJS = bpy.context.selected_objects
for BOOL_OBJECT in SEL_OBJS:
col.prop(self, "OBJECT_SETTINGS", text=BOOL_OBJECT.name)
if self.OBJECT_SETTINGS:
col.label(text=BOOL_OBJECT.name)
OK, I think I’m getting closer ,but still can’t figure this out. I think I need to use a Collection Property. I can draw the settings and they seem independent ,but I can’t execute the settings.
import bpy
class SelectedObjectPanel(bpy.types.Panel):
bl_label = "Selected Objects"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
def draw(self, context):
layout = self.layout
col = layout.column()
col.operator("object.selected_objects", text="Selected Objects")
class SelectedObjectProperties(bpy.types.PropertyGroup):
SELECTED: bpy.props.BoolProperty()
NAME: bpy.props.StringProperty()
OPERATION: bpy.props.EnumProperty(name="Operation",
items=(("UNION", "Union", "Use Union"),
("DIFFERENCE", "Difference", "Use Difference"),
("INTERSECT", "Intersect", "Use Intersect")),
description="Boolean Operation",
default="UNION")
class SelectedObject(bpy.types.Operator):
bl_idname = "object.selected_objects"
bl_label = "Selected Objects"
bl_options = {'REGISTER', 'UNDO'}
OBJS_COLLECTION: bpy.props.CollectionProperty(type=SelectedObjectProperties)
def __init__(self):
self.OBJS_COLLECTION.clear()
for OBJS in bpy.context.selected_objects:
ADD_TO_COLLECTION = self.OBJS_COLLECTION.add()
ADD_TO_COLLECTION.NAME = OBJS.name
def draw(self, context):
layout = self.layout
row = layout.row(align=True)
row.label(text="Objects")
row = layout.row(align=True)
for OBJS_SEL in self.OBJS_COLLECTION:
row.prop(OBJS_SEL, "SELECTED", text=OBJS_SEL.NAME)
col = layout.column(align=True)
col.label(text="Boolean Operations")
for OBJS_SEL in self.OBJS_COLLECTION:
if OBJS_SEL.SELECTED:
col = layout.column(align=True)
col.prop(OBJS_SEL, "OPERATION", text=OBJS_SEL.NAME)
def execute(self, context):
print(self.OBJS_COLLECTION.OPERATION)
return {'FINISHED'}
classes = (
SelectedObjectProperties,
SelectedObjectPanel,
SelectedObject
)
def register():
from bpy.utils import register_class
for cls in classes:
register_class(cls)
def unregister():
from bpy.utils import unregister_class
for cls in reversed(classes):
unregister_class(cls)
if __name__ == "__main__":
register()