error passing a property to a function (name not defined) I am fairly new to python scripting, so getting into blender is a uphill battle at the moment. I want to pass a property into the REDO panel that, when checked, tells the operator to take effect only to the active object. But I keep getting an error message saying that the property is not defined (it is my understanding that it should be, because of the self argument in the function).
Any help is very much appreciated!
    &quot;name&quot;: &quot;Snap Origin to selected&quot;,
    &quot;author&quot;: &quot;Juan&quot;,
    &quot;version&quot;: (1, 0),
    &quot;blender&quot;: (2, 90, 0),
    #&quot;location&quot;: &quot;View3D &gt; Mesh &gt; Snap &gt; Snap Origin to selected&quot;,
    &quot;description&quot;: &quot;snaps the origin of the object to a selection&quot;,
    &quot;category&quot;: &quot;Mesh&quot;,
}

import bpy

class MESH_OT_snapOrigin(bpy.types.Operator):
    &quot;&quot;&quot;It has to begin with a selected element in edit mode&quot;&quot;&quot;
    bl_idname = &quot;mesh.snap_origin_to_selected&quot;
    bl_label = &quot;Snap Origin to selected&quot;
    bl_options = {'REGISTER', 'UNDO'}
    
    only_active: bpy.props.BoolProperty(
        name=&quot;set only active&quot;,
        description=&quot;set only the origin of the active object&quot;,
        default=False,
    )
    

    @classmethod
    def poll(cls, context):
        return context.area.type == 'VIEW_3D'
    


    def execute(self, context):
        bpy.ops.view3d.snap_cursor_to_selected()
        bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
        if only_active.value is True:
           bpy.ops.objects.active.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')
        else:
           bpy.ops.object.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')
        # bpy.ops.object.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')
        print(&quot;updated!&quot;)
        return {'FINISHED'}

# Registration

def set_origin_button(self, context):
    self.layout.operator(
        MESH_OT_snapOrigin.bl_idname,
        text=&quot;snap origin to selected&quot;,
        icon='PIVOT_CURSOR')
        
        
def register():
    bpy.utils.register_class(MESH_OT_snapOrigin)
    bpy.types.VIEW3D_MT_edit_mesh.append(set_origin_button)

def unregister():
    bpy.utils.unregister_class(MESH_OT_snapOrigin)
    bpy.types.VIEW3D_MT_edit_mesh.remove(set_origin_button)

I also don't know if bpy.ops.objects.active.origin_set(type='ORIGIN_CURSOR', center='MEDIAN') is going to work, given that I get an error before that, just so you know...it is probably also wrong.
ok, so...I just had to add self. before the property for the function to recognize it (and lose the .value, since it is a boolean, but that's a different error). Like so:
if self.only_active is True:
I still don't know how to get the active object. The whole context part is particularly confusing to me. But I guess I'll get it eventually.