Passing PropertyGroup by reference, through a UI panel, to an operator: "read-only" error

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?

Operators can only take basic types like string, tuple, bool, int, float and some mathutils objects afaik.

You can store a dictionary with PropertyGroup instances you plan on accessing, and reference them by string on your operator. The argument you pass to the operator is the dictionary key.

Thank you, iceythe. After looking things up, apparently PointerProperties only work if they’re stored within a scene (e.g. context.scene.layer), or inside a PropertyGroup. So, short answer, it’s not possible. I wish Blender could be more liberal in variable types and scopes.

Anyways, what I’m doing as the solution for now is making an EnumProperty on the panel that switches between the layers. Since the property is stored at the scene level, all my operators can reference it freely and easily. It’s not as contained as I’d like, but it works.