Page MenuHome

Python execution of Rotate Operator around 3DCursor is failed
Closed, ArchivedPublic

Description

System Information
Operating system: windows 10
Graphics card: nvidia geforce 1050

Blender Version
all versions

Short description of error
In the 3DView, I set Transform Pivot Point to 3DCursor. Then I rotate some the Cube. Everything is ok. Blender automatically generate python code for this Rotate Operator.

The problem is that :  When i copy this python code into the Python Console, then the rotation is not around a 3DCursor.

Exact steps for others to reproduce the error

  • In 3DView, click the icon of Transform Pivot Point. Then in the dropped menu, choose obtion : 3DCursor.
  • Set the cursor position to some arbitrary position in the scene.
  • Set Rotate Tool to rotate the Cube.

Every thing is ok. Blender automatically generated python code for this Rotate Operation.
If you copy this python code, then paste this python code into the python console, and press enter, then you will see that the Rotate Operation is not around 3DCursor.

Event Timeline

Richard Antalik (ISS) changed the task status from Needs Triage to Needs Information from User.Mar 13 2020, 3:18 PM

Can you share python code you used?

1\ I made manual Rotate Operation by the following usual acts :

  • Open Blender, any versions. In this example, I use Blender 2.82a.
  • Manually set the 3dCursor position to some arbitrary place in the 3dView.
  • In 3DView, click the icon of Transform Pivot Point. Then in the dropped menu, choose obtion : 3DCursor.
  • Then manually rotate the 3d Cube. Everything is ok. The rotation is really made around the 3dCursor. This manual rotating procedure around 3dCursor is ok. And Blender automatically generates the python code of this rotation operator :

bpy.ops.transform.rotate(value=1.51442, orient_axis='Z', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, False, True), mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False, release_confirm=True)

2\ The problem appeared when i want to make this same rotation procedure by python script. For example, i copy the above python code, which is generated by blender, into python console. Then i press enter. Ops..... Problem occures : the rotation of this script is not around the 3dCursor.

I understand now, you copied operator command from info editor.

When I tried it it "generated" correct code:

bpy.ops.transform.rotate(value=-0.66547, orient_axis='Z', orient_type='VIEW', orient_matrix=((-0.410029, -0.911976, 0.0132648), (0.401743, -0.193644, -0.895045), (-0.818828, 0.361665, -0.445779)), orient_matrix_type='VIEW', mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False, center_override=(-1.84337, -3.49655, 0.549195))

You will need center_override=(-1.84337, -3.49655, 0.549195) parameter, but this is fixed point regardless where you press your 3D cursor. If you want this to be automatic you will need to add code to get 3D cursor position.

In any case the fact that center_override parameter was missing after you set transform pivot point to 3D cursor shouldn't happen I think. Does that happen even if you click on File > Defaults > Load Factory Settings?

thanks for your answer.
It is clearly that Blender python realizing of rotation operation around 3dcursor is error. It is not only error, but it is also the fool logic of bpy.ops.transform.rotate(..) operator. This error must not appear in new releases of Blender. The bpy.ops.transform.rotate(..) operator must automatically update and read the real conditions of the current scene to perform correct rotation.

thanks for your answer.
It is clearly that Blender python realizing of rotation operation around 3dcursor is error. It is not only error, but it is also the fool logic of bpy.ops.transform.rotate(..) operator. This error must not appear in new releases of Blender. The bpy.ops.transform.rotate(..) operator must automatically update and read the real conditions of the current scene to perform correct rotation.

The problem here is, that I can not reproduce this problem. Without steps, how to cause bug in first place, we don't know what to fix.

Can you upload simple .blend file, where rotating object would produce incorrect operator code?

It is very simple to reproduce this error. And I think that this problem of python rotation code of blender is very serious. It is very serious systematic mistake of blender python logic. Unfortunately this bug is on all blender versions, in 2.82a too.
Here a describe how to reproduce the error.
1/ Manually rotate the Cube in 3DView around 3dcursor.
You usually do it in the following procedure :

  • Open blender. In 3DView, manually set the 3dcursor to some arbitrary position in the scene.
  • In 3DView, manually set TransformPivotPoint to 3dcursor. Do it by clicking the TransformPivotPoint icon. Then in the dropped menu, choose : 3dcursor.
  • In 3DView, manually rotate the Cube.

Everythings are ok, the Cube is really rotated around 3dcursor.
But here, the problem beings.
if you open the Info window, you can see that Blender automatically generate the python code of the last rotating operation :
bpy.ops.transform.rotate(value=0.706834, orient_axis='Z', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, False, True), mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False, release_confirm=True).
Now you copy this code, then paste this code to the Console Window, then press enter, you will see that the same rotation occurred around other pivot point, not around 3dcursor. It is very stupid logic of Blender bpy.ops.trasform.rotate(…) operation. Because the generated code of bpy.ops.transform.rotate(..) does not contain any parameter, which show that the pivot point of current scene is 3dcurwor while the the TransformPivotPoint of current scene is really retained in option of 3dcursor.

Here I send you the  .blend file of this bug.  It is file of blender 2.82a{F8443660}

I think that your file haven't been saved.

You usually do it in the following procedure :

  • Open blender. In 3DView, manually set the 3dcursor to some arbitrary position in the scene.
  • In 3DView, manually set TransformPivotPoint to 3dcursor. Do it by clicking the TransformPivotPoint icon. Then in the dropped menu, choose : 3dcursor.
  • In 3DView, manually rotate the Cube.

After this, code in info editor in my case was

bpy.ops.transform.rotate(value=2.09445, orient_axis='Z', orient_type='VIEW', orient_matrix=((-0.410029, -0.911976, 0.0132648), (0.401743, -0.193644, -0.895045), (-0.818828, 0.361665, -0.445779)), orient_matrix_type='VIEW', mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False, center_override=(0.30442, 2.84308, 1.74744))

And it works well when run from console.

Does this happen if you click on File > Defaults > Load Factory Settings?

I load File>Defaults<Load Factory Settings.
But the autogenerated code of rotating around 3dcursor is :
bpy.ops.transform.rotate(value=2.09445, orient_axis='Z', orient_type='VIEW', orient_matrix=((-0.410029, -0.911976, 0.0132648), (0.401743, -0.193644, -0.895045), (-0.818828, 0.361665, -0.445779)), orient_matrix_type='VIEW', mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False, center_override=(0.30442, 2.84308, 1.74744)).
The generated code does not contain parameter : center_override=(0.30442, 2.84308, 1.74744)

I can reproduce this in 2.82, but not in 2.83, so please test in 2.83

Richard Antalik (ISS) closed this task as Archived.Apr 16 2020, 10:59 PM

No activity for more than a week. As per the tracker policy we assume the issue is gone and can be closed.

Thanks again for the report. If the problem persists please open a new report with the required information.

Problem still reproducable in 2.83

I was searching why my object wasnt rotating around the 3D Cursor when copying the Python code from the console logger into my script. Then i found this bug.

@Matthias Thurau (Zweistein) I have re-checked this and I have found that there is some issue but I can't find the root cause. Sometimes even opening new file affected this behavior, which shouldn't happen.
Please create new report as this one is closed already.

Reporting same error in my fresh blender install.

This is a very primitive error and I dont see how it occurs only a few times.
I am not getting center_override=(x, y, z)) .
I am assuming x,y,z are the coordinates of 3DCursor. If that is the case, Do we have a way to find out these using bpy?