I have multiple instances of
class LayerSettings(bpy.types.PropertyGroup) , which is simply a group of variables. These are stored at the scene level (they’re a predefined number, but many of them). My operators work with different instances of the settings depending on which part of the UI they select (one button executes the operator with settings A, another does the same operator with settings B, etc.).
I’d like to pass the reference of the property group to these operators in the UI.
class SM_OT_layer_calculator(bpy.types.Operator): layer: bpy.props.PointerProperty(type=LayerSettings) def execute(self, context): # use self.layer...
When I call the following in my panel:
layout.operator(SM_OT_layer_calculator.bl_idname, text="Calculate").layer = layer_settings_arg
It gives me an error:
attribute "layer" from "SM_OT_video_calculator" is read-only . I can’t find anything in the documentation or in StackExchange on how to assign properties (there’s ones for a collection prop, but it has an add function that PointerProps don’t). I know hard-coding is an option for each instance, but that’s hard to maintain and debug.
Is there a way to pass a reference of a property group instance to an operator, with the UI?