I want to apply the uv.select_split and after that the transform.traslate, but dynamically.

Manually is really easy, you press Y and then press G.

With python I tried this in the Image-Editor:


But I always need specify the values to transform.translate and I don't want that. I want to set it like the G key.

Any ideas on how to do this?


To invoke the operator as if you pressed the G key you can simply do the following:


Note that you have to have your mouse cursor placed in the correct area.

This works according to the documentation of Operators/Execution Context:

When calling an operator you may want to pass the execution context.

This determines the context that is given for the operator to run in, and whether invoke() is called or only execute().

‘EXEC_DEFAULT’ is used by default, running only the execute() method, but you may want the operator to take user interaction with ‘INVOKE_DEFAULT’ which will also call invoke() if existing.

The last sentence is crucial. Operators like translate that run until the user confirmed further inputs (keystrokes and/or mouse movement) are called modal operators. They have to be invoked for them to take user input, else you have to give parameters.

Note: Possibly something interesting for you is that you can override the context of an operator (the area it is run in) to be the UV editor. You have to call the operator as

bpy.ops.transform.translate('INVOKE_DEFAULT', {'area': areaoverride})

where areaoverride is one of bpy.data.screens[idx].areas with any valid index idx.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.