Python method Set Pivot to unmasked has no effect #73859

Closed
opened 2020-02-16 00:35:42 +01:00 by Matthias Pieroth · 21 comments

System Information
Operating system: Win 10
Graphics card: NVidia GTX 1060

Blender Version
2.83 Master

Short description of error
I call this line of Python code in the invoke method of an operator in sculpt mode, the move tool is selected:

bpy.ops.sculpt.set_pivot_position(mode='UNMASKED')

But the gizmo doesnt move to the unmasked area of the mesh. When I do the same operation using the UI (Toolbar: Set Pivot) it works.

I debugged the Blender code and the function

static int sculpt_set_pivot_position_invoke(bContext *C, wmOperator *op, const wmEvent *event)

isn't executed for the Python call.

Operators like the mask_flood_fill can be called for they have exec-API callback - does set_pivot_position need an exec-callback as well so that it can be called by Python?

**System Information** Operating system: Win 10 Graphics card: NVidia GTX 1060 **Blender Version** 2.83 Master **Short description of error** I call this line of Python code in the invoke method of an operator in sculpt mode, the move tool is selected: bpy.ops.sculpt.set_pivot_position(mode='UNMASKED') But the gizmo doesnt move to the unmasked area of the mesh. When I do the same operation using the UI (Toolbar: Set Pivot) it works. I debugged the Blender code and the function static int sculpt_set_pivot_position_invoke(bContext *C, wmOperator *op, const wmEvent *event) isn't executed for the Python call. Operators like the *mask_flood_fill* can be called for they have exec-API callback - does *set_pivot_position* need an exec-callback as well so that it can be called by Python?

Added subscriber: @Jayanam

Added subscriber: @Jayanam
Pablo Dobarro was assigned by Matthias Pieroth 2020-02-16 17:25:31 +01:00

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'

We require steps to reproduce the problem.
This facilitates the investigation process.

We require steps to reproduce the problem. This facilitates the investigation process.

@mano-wii

  1. Go to sculpt mode, remesh a cube to increase the resolution
  2. Add a simple mask with the mask brush, invert the mask
  3. Select the move tool/brush
  4. open a Python console and type in
bpy.ops.sculpt.set_pivot_position(mode='UNMASKED')

to invoke the set_pivot_position operator

image.png

Nothing happens, it is not invoked.

@mano-wii 1. Go to sculpt mode, remesh a cube to increase the resolution 2. Add a simple mask with the mask brush, invert the mask 3. Select the move tool/brush 4. open a Python console and type in ``` bpy.ops.sculpt.set_pivot_position(mode='UNMASKED') ``` to invoke the set_pivot_position operator ![image.png](https://archive.blender.org/developer/F8345569/image.png) Nothing happens, it is not invoked.

Changed status from 'Needs User Info' to: 'Needs Triage'

Changed status from 'Needs User Info' to: 'Needs Triage'
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

It seems to work when you do this: bpy.ops.sculpt.set_pivot_position('INVOKE_DEFAULT', mode='UNMASKED'). Does this solve your issue?

It seems to work when you do this: `bpy.ops.sculpt.set_pivot_position('INVOKE_DEFAULT', mode='UNMASKED')`. Does this solve your issue?

Changed status from 'Needs User Info' to: 'Archived'

Changed status from 'Needs User Info' to: 'Archived'

The problem is that this operator does not have an exec callback.
You can work around the problem by specifying the context 'INVOKE_DEFAULT'.
https://docs.blender.org/api/current/bpy.ops.html#execution-context

Thanks for the report, but this is not considered a bug. Closing as this bug tracker is only for bugs and errors.

For user requests and feedback, please use other channels: https://wiki.blender.org/wiki/Communication/Contact#User_Feedback_and_Requests

The problem is that this operator does not have an exec callback. You can work around the problem by specifying the context `'INVOKE_DEFAULT'`. https://docs.blender.org/api/current/bpy.ops.html#execution-context Thanks for the report, but this is not considered a bug. Closing as this bug tracker is only for bugs and errors. For user requests and feedback, please use other channels: https://wiki.blender.org/wiki/Communication/Contact#User_Feedback_and_Requests

Added subscriber: @brecht

Added subscriber: @brecht

Changed status from 'Archived' to: 'Confirmed'

Changed status from 'Archived' to: 'Confirmed'

I consider this a bug, there's no way a user of the Python API can know this without looking at the source code.

It should call invoke instead of exec automatically in this case.

I consider this a bug, there's no way a user of the Python API can know this without looking at the source code. It should call invoke instead of exec automatically in this case.

This operator could also get an exec callback, there's only very few types of operators that need only invoke and no exec.

This operator could also get an `exec` callback, there's only very few types of operators that need only `invoke` and no `exec`.

@JacquesLucke Basically yes, but then we have two possibilities: The API documentation has to be changed, or the first parameter has to be used internally - I guess the second solution is better cause other Python method calls don't need this parameter either.

Or even better, as I mentioned in the issue, the operator should get an exec-API callback.

@JacquesLucke Basically yes, but then we have two possibilities: The API documentation has to be changed, or the first parameter has to be used internally - I guess the second solution is better cause other Python method calls don't need this parameter either. Or even better, as I mentioned in the issue, the operator should get an exec-API callback.
Pablo Dobarro was unassigned by Jacques Lucke 2020-02-18 13:54:21 +01:00
Jacques Lucke self-assigned this 2020-02-18 13:54:21 +01:00
Member

Added subscriber: @PabloDobarro

Added subscriber: @PabloDobarro
Member

I'll put the code in the exec method and pass the mouse position from invoke to exec using new properties on the operator.

I'll put the code in the `exec` method and pass the mouse position from `invoke` to `exec` using new properties on the operator.

@JacquesLucke : Ok, just to let you know, I applied the diff, compiled and it works in my operator and from the Python Console as well.

@JacquesLucke : Ok, just to let you know, I applied the diff, compiled and it works in my operator and from the Python Console as well.

This issue was referenced by blender/blender@d54a4a32f3

This issue was referenced by blender/blender@d54a4a32f386890c39a4d0b783b957a0619af3a5
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sign in to join this conversation.
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#73859
No description provided.