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'}
@classmethod
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
print(context.tool_settings.proportional_size)
# only prints <bpy_struct, FloatProperty("proportional_size") at 0x000001AD0DBB6CE8>
# but not the current value of the property
print(self.prop)
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']
op('INVOKE_DEFAULT')
wm = context.window_manager
wm.modal_handler_add(self)
return {'RUNNING_MODAL'}
bpy.utils.register_class(TRANSFORM_OT_translate_new)
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.
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…
@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++.