Previous Thread  Next Thread

chat icon object EDIT mode/how set: vertex, edge, or face select mode

wretch1958

Posted: Thu Mar 29, 2012 5:54 am
Joined: 29 Mar 2012
Posts: 21
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.mode_set(mode='EDIT')
The above API commands allow me to switch between OBJECT and EDIT modes. Once I am in EDIT mode, is there a Python command to specify or switch between Vertex Select Mode, Edge Select Mode, and Face Select Mode?????
My goal is to merge certain vertices by doing this:
current_obj.data.vertices[0].select = True
current_obj.data.vertices[1].select = True
bpy.ops.mesh.merge(type='CENTER', uvs=False)
But if the context in EDIT mode is anything other than vertex select mode, in my case it is usually in face select mode) then setting vertices[n] = True does not work. So I need to set context to vertex selection mode with a Python command.

By the way, why do I have to be in OBJECT mode to select vertices (but prior to this, while in EDIT mode, set vertex selection mode), then go back in EDIT mode to merge them. This seems counterintuitive and a lot of jumping back and forth when it really all should happen in EDIT mode?

Thanks ahead of time for any help!
Reply with quote


ldo

Posted: Sun Apr 01, 2012 2:02 am
Joined: 07 Nov 2010
Posts: 543
Code:
context.tool_settings.mesh_select_mode = (vertex, edge, face)


where each of vertex, edge and face is True or False to enable or disable the corresponding selection mode.
Reply with quote


wretch1958

Posted: Wed Apr 04, 2012 11:44 pm
Joined: 29 Mar 2012
Posts: 21
Thank you 'ldo', that works great.
Reply with quote


SpAiK

Posted: Fri Sep 21, 2012 4:11 pm
Joined: 27 Sep 2008
Posts: 7
ldo wrote:
Code:
context.tool_settings.mesh_select_mode = (vertex, edge, face)


where each of vertex, edge and face is True or False to enable or disable the corresponding selection mode.


Hi, I'm looking for a way to assign that to hotkeys, so for example I could change between vertex, edge or face edit modes with 1, 2, 3 keyboard keys. Is that possible?
Reply with quote


dustractor

Posted: Fri Sep 21, 2012 9:44 pm
Joined: 10 Dec 2007
Posts: 11
If you don't mind a combo... [Ctrl]+[Tab] then hit [1], [2], or [3] while in edit mode, for vert,edge,face, respectively.

Most of the menu items respond to numeric keys according to their index on the menu -- for example: [shift] + [s] brings up the menu for 3d-cursor-type-stuff, since the fourth thing is cursor to center, so [shift] + [s] , [4] is the shortcut to set the cursor to the origin.


Although I must admit, I have thought about how nice it would be to have single-key shortcuts for the v e and f modes. I just never bothered to write a script.
Reply with quote


SpAiK

Posted: Mon Sep 24, 2012 10:12 am
Joined: 27 Sep 2008
Posts: 7
I was using the combo but I realized it was a bit tedious to have use three keys for that instead of using only one, what would be faster.
Reply with quote


CoDEmanX

Posted: Mon Sep 24, 2012 5:43 pm
Joined: 05 Apr 2009
Posts: 680
you can, see here:
http://cgcookie.com/blender/2010/05/17/custom-hot-keys/

basically add hotkeys,
operator: wm.context_set_value
data path: tool_settings.mesh_select_mode
value: False, True, False (for edge mode)
_________________
I'm sitting, waiting, wishing, building Blender in superstition...
Reply with quote


SpAiK

Posted: Mon Sep 24, 2012 7:28 pm
Joined: 27 Sep 2008
Posts: 7
CoDEmanX wrote:
you can, see here:
http://cgcookie.com/blender/2010/05/17/custom-hot-keys/

basically add hotkeys,
operator: wm.context_set_value
data path: tool_settings.mesh_select_mode
value: False, True, False (for edge mode)


Thank you so much! This is what I was looking for. I was trying myself to create hotkeys but they weren't working.
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group