Page MenuHome

Strange behaviour when selecting geometry in python and using that geometry to do mesh operations via user interface
Closed, ArchivedPublic

Description

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

Event Timeline

Dalai Felinto (dfelinto) changed the task status from Unknown Status to Archived.Feb 24 2017, 6:32 PM
Dalai Felinto (dfelinto) claimed this task.

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 T38676

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.