Strange behaviour when selecting geometry in python and using that geometry to do mesh operations via user interface #50771

Closed
opened 2017-02-24 14:03:58 +01:00 by Roel Koster · 5 comments
Member

System Information
OSX iMac 5k

Blender Version
2.78b

Short description of error
You need to do a 'physical' object mode toggle instead of programming that toggle to do mesh operations on python selected faces/edges/polys

Exact steps for others to reproduce the error

  • Add a cube
  • Enter this in console:
obj=C.object
pols=obj.data.polygons
bpy.ops.object.mode_set(mode = 'EDIT') 
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.object.mode_set(mode = 'OBJECT') 
pols[0].select=True
bpy.ops.object.mode_set(mode = 'EDIT') 
bpy.ops.object.mode_set(mode = 'OBJECT') 
pols[1].select=True
bpy.ops.object.mode_set(mode = 'EDIT') 

press I (for inset)
Should work as expected
press F6 to tweak

Observe Erratic behaviour: Nothing gets updated!

Observation: before pressing I, toggle Object/Edit mode by hand (TAB) and then use Inset will work
Toggling by python instead of by hand won't make it work..

I've noticed this problem when working on a script which does the following:
Enter Edit mode, and as an example set Face Selection Mode.
Select faces
Put those selected faces.indices in a buffer
Select other faces
Do a boolean operation on those two selections
Works as expected..
However, with those selected faces, trying a mesh operation like inset or bevel will work at first, but when pressing F6 afterwards, Blender will instantly revert back to it's last 'official' selection..
A little bit different in result, but similar.. hope this is the same bug.
The script needs to toggle back and forth between EDIT/OBJECT mode, thus creating a similar situation as in the bug report..
To prevent F6 from failing, I have to toggle MANUALLY between EDIT/OBJECT mode to get it to accept the complete selection. Python toggling the mode won't help..

Hope it all makes sense,
Regards,
Roel

**System Information** OSX iMac 5k **Blender Version** 2.78b **Short description of error** You need to do a 'physical' object mode toggle instead of programming that toggle to do mesh operations on python selected faces/edges/polys **Exact steps for others to reproduce the error** - Add a cube - Enter this in console: ``` obj=C.object pols=obj.data.polygons bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.select_all(action = 'DESELECT') bpy.ops.object.mode_set(mode = 'OBJECT') pols[0].select=True bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.object.mode_set(mode = 'OBJECT') pols[1].select=True bpy.ops.object.mode_set(mode = 'EDIT') ``` press I (for inset) Should work as expected press F6 to tweak Observe Erratic behaviour: Nothing gets updated! Observation: before pressing I, toggle Object/Edit mode by hand (TAB) and then use Inset will work Toggling by python instead of by hand won't make it work.. I've noticed this problem when working on a script which does the following: Enter Edit mode, and as an example set Face Selection Mode. Select faces Put those selected faces.indices in a buffer Select other faces Do a boolean operation on those two selections Works as expected.. However, with those selected faces, trying a mesh operation like inset or bevel will work at first, but when pressing F6 afterwards, Blender will instantly revert back to it's last 'official' selection.. A little bit different in result, but similar.. hope this is the same bug. The script needs to toggle back and forth between EDIT/OBJECT mode, thus creating a similar situation as in the bug report.. To prevent F6 from failing, I have to toggle MANUALLY between EDIT/OBJECT mode to get it to accept the complete selection. Python toggling the mode won't help.. Hope it all makes sense, Regards, Roel
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @kostex

Added subscriber: @kostex

Added subscriber: @dfelinto

Added subscriber: @dfelinto

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Dalai Felinto self-assigned this 2017-02-24 18:32:45 +01:00

It's not a bug, you need to push undo via Python:

https://docs.blender.org/api/blender_python_api_master/bpy.ops.ed.html?highlight=undo#bpy.ops.ed.undo_push

It's related to blender/blender#38676

In other words, if you do bpy.ops.ed.undo_push() before doing 'i', it works fine. Closing the report for now. Let me know if the problem persist, so I can re-open it.

It's not a bug, you need to push undo via Python: https://docs.blender.org/api/blender_python_api_master/bpy.ops.ed.html?highlight=undo#bpy.ops.ed.undo_push It's related to blender/blender#38676 In other words, if you do bpy.ops.ed.undo_push() before doing 'i', it works fine. Closing the report for now. Let me know if the problem persist, so I can re-open it.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 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#50771
No description provided.