Get current value of built-in modal operator

Hi there,

I’m trying to create an add-on. I’m trying to “extend” a built-in operator whit some additional functions. While that is possible in a way shown in the code below, what I need is a way to access the “proportional_size” value while the built-in transform.translate operator is running modal.
The code below hopefully gives further inside of what I’m trying to do and also what doesn’t seem to work…

import bpy

class TRANSFORM_OT_translate_new(bpy.types.Operator):
    bl_idname = "transform.translate_new"
    bl_label = "Tranlate New"
    bl_options = {'REGISTER', 'UNDO'}

    def poll(cls, context):
        obj_sel = context.object is not None
        return obj_sel

    def modal(self, context, event):
        if event.type in ['WHEELUPMOUSE', 'WHEELDOWNMOUSE']:
            # only prints value set before starting modal operator
            # only prints <bpy_struct, FloatProperty("proportional_size") at 0x000001AD0DBB6CE8>
            # but not the current value of the property

        return {'PASS_THROUGH'}

    def invoke(self, context, event):
        op = bpy.ops.transform.translate
        # get operator property itself
        self.prop = op.get_rna_type().properties['proportional_size']

        wm = context.window_manager

        return {'RUNNING_MODAL'}


The value seems to be updated only after running the modal operator.
There also seems to be the “_bpy” module to access internal operators. But it doesn’t seem to be documented anywhere.

A lot of stuff isn’t documented. Any way I don’t think this line:

self.prop = op.get_rna_type().properties['proportional_size']

Does what you think… That should set prop to the default value of the op objects ‘proportional_size’ property. It’s not a pointer to any actual value. So your prop value will not change unless something directly sets it to a new value.

My understanding of get_rna_type().properties is that they are the template properties for that object type and not instanced values…

I used the creation and read of properties here:

No it’s not documented and for the few things that are, the doc is out of any user-friendliness :confused:

However this might help a bit ?
or not.

Good luck and happy blending !

Thanks for the answers so far.

@netherby I more or less came to the same conclusion. I mostly added that part of the code, hoping somebody might have done something similar and also tried to show, what didn’t work. Guess I didn’t communicate that good enough in the initial post.

@pitibonom I read the code you’ve written, but to my understanding every property you access is defined within the python API. That’s pretty much my main problem. The operator property I’m trying to get is completely written in C/C++.

In other threads people even called working with Blender-C-operators “python dark magic”.
So it also might be not that wise to mess with it.