I’ve made a little script that could be useful for those that do not use the 1-3 keys to set collections visibility.
It works the same way in object mode as in edit mode. In object mode, enters edit mode and selects vertex, edge, face
bl_info = {
"name": "AR Select",
"category": "Object",
"blender": (2, 80, 0),
"author": "AR d-V-b",
}
import bpy
class ARSelect(bpy.types.Operator):
"""ARSelect"""
bl_idname = 'object.ar_select'
bl_label = 'Edit Select (AR)'
bl_options = {'UNDO'} #'REGISTER'
m_select_type: bpy.props.EnumProperty(
name = 'Mesh Select Type',
items = [
('VERT', 'Vertex', 'Select Vertex'),
('EDGE', 'Edge', 'Select Edge'),
('FACE', 'Face', 'Select Face'),
]
)
g_select_type : bpy.props.EnumProperty(
name = 'GP Select Type',
items = [
('0', 'Point', 'Select Point'),
('1', 'Stroke', 'Select Stroke'),
('2', 'Segment', 'Select Segment'),
]
)
def execute(self, context):
if bpy.context.object.type == 'MESH':
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_mode(
use_extend=False,
use_expand=False,
type=self.m_select_type)
elif bpy.context.object.type == 'GPENCIL':
bpy.ops.gpencil.editmode_toggle()
bpy.ops.gpencil.selectmode_toggle(mode=int(self.g_select_type))
else:
return {'CANCELLED'}
return {'FINISHED'}
_keys = []
def register():
bpy.utils.register_class(ARSelect)
wm = bpy.context.window_manager
km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')
kmi = km.keymap_items.new(ARSelect.bl_idname, 'ONE', 'PRESS', ctrl=False, shift=False)
kmi.properties.m_select_type = 'VERT'
kmi.properties.g_select_type = '0'
kmi = km.keymap_items.new(ARSelect.bl_idname, 'TWO', 'PRESS', ctrl=False, shift=False)
kmi.properties.m_select_type = 'EDGE'
kmi.properties.g_select_type = '1'
kmi = km.keymap_items.new(ARSelect.bl_idname, 'THREE', 'PRESS', ctrl=False, shift=False)
kmi.properties.m_select_type = 'FACE'
kmi.properties.g_select_type = '2'
_keys.append(km)
def unregister():
bpy.utils.unregister_class(ARSelect)
wm = bpy.context.window_manager
for km in _keys:
wm.keyconfigs.addon.keymaps.remove(km)
del _keys[:]
if __name__ == "__main__":
register()