Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-03-05 04:32:28 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-03-05 04:32:28 +0300
commitaec5a36c12a3ec1d068adb8270017e509087dff6 (patch)
treedcc0408cf538f1fb39a41dd84c775342863b8a32 /space_view3d_spacebar_menu
parent353492b181e08663b8cd3bc5733920b6fcdbcbe4 (diff)
Cleanup: tabs -> spaces
Diffstat (limited to 'space_view3d_spacebar_menu')
-rw-r--r--space_view3d_spacebar_menu/__init__.py28
-rw-r--r--space_view3d_spacebar_menu/edit_mesh.py302
-rw-r--r--space_view3d_spacebar_menu/snap_origin_cursor.py406
3 files changed, 368 insertions, 368 deletions
diff --git a/space_view3d_spacebar_menu/__init__.py b/space_view3d_spacebar_menu/__init__.py
index c46aea7f..51a7d4dd 100644
--- a/space_view3d_spacebar_menu/__init__.py
+++ b/space_view3d_spacebar_menu/__init__.py
@@ -827,20 +827,20 @@ class VIEW3D_MT_Space_Dynamic_Menu(Menu):
# Text Edit Mode
def menu_func(self, context):
- layout = self.layout
-
- layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
- layout.menu("VIEW3D_MT_select_edit_text", icon='VIEW3D')
- layout.separator()
- layout.operator_context = 'INVOKE_REGION_WIN'
- layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
- layout.menu("VIEW3D_MT_Animation_Player",
- text="Animation", icon='PLAY')
- layout.menu("SCREEN_MT_user_menu", text="Quick Favorites", icon='HEART')
- layout.operator("object.editmode_toggle", text="Enter Object Mode",
- icon='OBJECT_DATA')
- layout.separator()
- layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
+ layout = self.layout
+
+ layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
+ layout.menu("VIEW3D_MT_select_edit_text", icon='VIEW3D')
+ layout.separator()
+ layout.operator_context = 'INVOKE_REGION_WIN'
+ layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
+ layout.menu("VIEW3D_MT_Animation_Player",
+ text="Animation", icon='PLAY')
+ layout.menu("SCREEN_MT_user_menu", text="Quick Favorites", icon='HEART')
+ layout.operator("object.editmode_toggle", text="Enter Object Mode",
+ icon='OBJECT_DATA')
+ layout.separator()
+ layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
# Preferences utility functions
diff --git a/space_view3d_spacebar_menu/edit_mesh.py b/space_view3d_spacebar_menu/edit_mesh.py
index eff16c0d..c7098c69 100644
--- a/space_view3d_spacebar_menu/edit_mesh.py
+++ b/space_view3d_spacebar_menu/edit_mesh.py
@@ -20,13 +20,13 @@
import bpy
from bpy.types import (
- Operator,
- Menu,
- )
+ Operator,
+ Menu,
+ )
from bpy.props import (
- BoolProperty,
- StringProperty,
- )
+ BoolProperty,
+ StringProperty,
+ )
from .object_menus import *
from .snap_origin_cursor import *
@@ -36,210 +36,210 @@ from .snap_origin_cursor import *
# ********** Edit Multiselect **********
class VIEW3D_MT_Edit_Multi(Menu):
- bl_label = "Mode Select"
+ bl_label = "Mode Select"
- def draw(self, context):
- layout = self.layout
+ def draw(self, context):
+ layout = self.layout
- layout.operator("selectedit.vertex", text="Vertex", icon='VERTEXSEL')
- layout.operator("selectedit.edge", text="Edge", icon='EDGESEL')
- layout.operator("selectedit.face", text="Face", icon='FACESEL')
- layout.operator("selectedit.vertsfaces", text="Vertex/Faces", icon='VERTEXSEL')
- layout.operator("selectedit.vertsedges", text="Vertex/Edges", icon='EDGESEL')
- layout.operator("selectedit.edgesfaces", text="Edges/Faces", icon='FACESEL')
- layout.operator("selectedit.vertsedgesfaces", text="Vertex/Edges/Faces", icon='OBJECT_DATAMODE')
+ layout.operator("selectedit.vertex", text="Vertex", icon='VERTEXSEL')
+ layout.operator("selectedit.edge", text="Edge", icon='EDGESEL')
+ layout.operator("selectedit.face", text="Face", icon='FACESEL')
+ layout.operator("selectedit.vertsfaces", text="Vertex/Faces", icon='VERTEXSEL')
+ layout.operator("selectedit.vertsedges", text="Vertex/Edges", icon='EDGESEL')
+ layout.operator("selectedit.edgesfaces", text="Edges/Faces", icon='FACESEL')
+ layout.operator("selectedit.vertsedgesfaces", text="Vertex/Edges/Faces", icon='OBJECT_DATAMODE')
# ********** Edit Mesh Edge **********
class VIEW3D_MT_EditM_Edge(Menu):
- bl_label = "Edges"
+ bl_label = "Edges"
- def draw(self, context):
- layout = self.layout
- layout.operator_context = 'INVOKE_REGION_WIN'
+ def draw(self, context):
+ layout = self.layout
+ layout.operator_context = 'INVOKE_REGION_WIN'
- layout.operator("mesh.mark_seam")
- layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
- layout.separator()
+ layout.operator("mesh.mark_seam")
+ layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
+ layout.separator()
- layout.operator("mesh.mark_sharp")
- layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
- layout.operator("mesh.extrude_move_along_normals", text="Extrude")
- layout.separator()
+ layout.operator("mesh.mark_sharp")
+ layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
+ layout.operator("mesh.extrude_move_along_normals", text="Extrude")
+ layout.separator()
- layout.operator("mesh.edge_rotate",
- text="Rotate Edge CW").direction = 'CW'
- layout.operator("mesh.edge_rotate",
- text="Rotate Edge CCW").direction = 'CCW'
- layout.separator()
+ layout.operator("mesh.edge_rotate",
+ text="Rotate Edge CW").direction = 'CW'
+ layout.operator("mesh.edge_rotate",
+ text="Rotate Edge CCW").direction = 'CCW'
+ layout.separator()
- layout.operator("TFM_OT_edge_slide", text="Edge Slide")
- layout.operator("mesh.loop_multi_select", text="Edge Loop")
- layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
- layout.operator("mesh.loop_to_region")
- layout.operator("mesh.region_to_loop")
+ layout.operator("TFM_OT_edge_slide", text="Edge Slide")
+ layout.operator("mesh.loop_multi_select", text="Edge Loop")
+ layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
+ layout.operator("mesh.loop_to_region")
+ layout.operator("mesh.region_to_loop")
# multiple edit select modes.
class VIEW3D_OT_selecteditVertex(Operator):
- bl_idname = "selectedit.vertex"
- bl_label = "Vertex Mode"
- bl_description = "Vert Select"
- bl_options = {'REGISTER', 'UNDO'}
+ bl_idname = "selectedit.vertex"
+ bl_label = "Vertex Mode"
+ bl_description = "Vert Select"
+ bl_options = {'REGISTER', 'UNDO'}
- def execute(self, context):
- if context.object.mode != "EDIT":
- bpy.ops.object.mode_set(mode="EDIT")
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
- if bpy.ops.mesh.select_mode != "EDGE, FACE":
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
- return {'FINISHED'}
+ def execute(self, context):
+ if context.object.mode != "EDIT":
+ bpy.ops.object.mode_set(mode="EDIT")
+ bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
+ if bpy.ops.mesh.select_mode != "EDGE, FACE":
+ bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
+ return {'FINISHED'}
class VIEW3D_OT_selecteditEdge(Operator):
- bl_idname = "selectedit.edge"
- bl_label = "Edge Mode"
- bl_description = "Edge Select"
- bl_options = {'REGISTER', 'UNDO'}
+ bl_idname = "selectedit.edge"
+ bl_label = "Edge Mode"
+ bl_description = "Edge Select"
+ bl_options = {'REGISTER', 'UNDO'}
- def execute(self, context):
- if context.object.mode != "EDIT":
- bpy.ops.object.mode_set(mode="EDIT")
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
- if bpy.ops.mesh.select_mode != "VERT, FACE":
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
- return {'FINISHED'}
+ def execute(self, context):
+ if context.object.mode != "EDIT":
+ bpy.ops.object.mode_set(mode="EDIT")
+ bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
+ if bpy.ops.mesh.select_mode != "VERT, FACE":
+ bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
+ return {'FINISHED'}
class VIEW3D_OT_selecteditFace(Operator):
- bl_idname = "selectedit.face"
- bl_label = "Multiedit Face"
- bl_description = "Face Mode"
- bl_options = {'REGISTER', 'UNDO'}
+ bl_idname = "selectedit.face"
+ bl_label = "Multiedit Face"
+ bl_description = "Face Mode"
+ bl_options = {'REGISTER', 'UNDO'}
- def execute(self, context):
- if context.object.mode != "EDIT":
- bpy.ops.object.mode_set(mode="EDIT")
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE')
- if bpy.ops.mesh.select_mode != "VERT, EDGE":
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE')
- return {'FINISHED'}
+ def execute(self, context):
+ if context.object.mode != "EDIT":
+ bpy.ops.object.mode_set(mode="EDIT")
+ bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE')
+ if bpy.ops.mesh.select_mode != "VERT, EDGE":
+ bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE')
+ return {'FINISHED'}
# Components Multi Selection Mode
class VIEW3D_OT_selecteditVertsEdges(Operator):
- bl_idname = "selectedit.vertsedges"
- bl_label = "Verts Edges Mode"
- bl_description = "Vert/Edge Select"
- bl_options = {'REGISTER', 'UNDO'}
-
- def execute(self, context):
- if context.object.mode != "EDIT":
- bpy.ops.object.mode_set(mode="EDIT")
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
- if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE":
- bpy.ops.object.mode_set(mode="EDIT")
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
- bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='EDGE')
- return {'FINISHED'}
+ bl_idname = "selectedit.vertsedges"
+ bl_label = "Verts Edges Mode"
+ bl_description = "Vert/Edge Select"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ def execute(self, context):
+ if context.object.mode != "EDIT":
+ bpy.ops.object.mode_set(mode="EDIT")
+ bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
+ if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE":
+ bpy.ops.object.mode_set(mode="EDIT")
+ bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
+ bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='EDGE')
+ return {'FINISHED'}
class VIEW3D_OT_selecteditEdgesFaces(Operator):
- bl_idname = "selectedit.edgesfaces"
- bl_label = "Edges Faces Mode"
- bl_description = "Edge/Face Select"
- bl_options = {'REGISTER', 'UNDO'}
-
- def execute(self, context):
- if context.object.mode != "EDIT":
- bpy.ops.object.mode_set(mode="EDIT")
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
- if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE":
- bpy.ops.object.mode_set(mode="EDIT")
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
- bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='FACE')
- return {'FINISHED'}
+ bl_idname = "selectedit.edgesfaces"
+ bl_label = "Edges Faces Mode"
+ bl_description = "Edge/Face Select"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ def execute(self, context):
+ if context.object.mode != "EDIT":
+ bpy.ops.object.mode_set(mode="EDIT")
+ bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
+ if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE":
+ bpy.ops.object.mode_set(mode="EDIT")
+ bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
+ bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='FACE')
+ return {'FINISHED'}
class VIEW3D_OT_selecteditVertsFaces(Operator):
- bl_idname = "selectedit.vertsfaces"
- bl_label = "Verts Faces Mode"
- bl_description = "Vert/Face Select"
- bl_options = {'REGISTER', 'UNDO'}
-
- def execute(self, context):
- if context.object.mode != "EDIT":
- bpy.ops.object.mode_set(mode="EDIT")
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
- if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE":
- bpy.ops.object.mode_set(mode="EDIT")
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
- bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='FACE')
- return {'FINISHED'}
+ bl_idname = "selectedit.vertsfaces"
+ bl_label = "Verts Faces Mode"
+ bl_description = "Vert/Face Select"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ def execute(self, context):
+ if context.object.mode != "EDIT":
+ bpy.ops.object.mode_set(mode="EDIT")
+ bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
+ if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE":
+ bpy.ops.object.mode_set(mode="EDIT")
+ bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
+ bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='FACE')
+ return {'FINISHED'}
class VIEW3D_OT_selecteditVertsEdgesFaces(Operator):
- bl_idname = "selectedit.vertsedgesfaces"
- bl_label = "Verts Edges Faces Mode"
- bl_description = "Vert/Edge/Face Select"
- bl_options = {'REGISTER', 'UNDO'}
-
- def execute(self, context):
- if context.object.mode != "EDIT":
- bpy.ops.object.mode_set(mode="EDIT")
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
- if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE":
- bpy.ops.object.mode_set(mode="EDIT")
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
- bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='EDGE')
- bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='FACE')
- return {'FINISHED'}
+ bl_idname = "selectedit.vertsedgesfaces"
+ bl_label = "Verts Edges Faces Mode"
+ bl_description = "Vert/Edge/Face Select"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ def execute(self, context):
+ if context.object.mode != "EDIT":
+ bpy.ops.object.mode_set(mode="EDIT")
+ bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
+ if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE":
+ bpy.ops.object.mode_set(mode="EDIT")
+ bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
+ bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='EDGE')
+ bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='FACE')
+ return {'FINISHED'}
# ********** Normals / Auto Smooth Menu **********
# Thanks to marvin.k.breuer for the Autosmooth part of the menu
def menu_func(self, context):
- layout = self.layout
- obj = context.object
- obj_data = context.active_object.data
- layout.separator()
- layout.prop(obj_data, "use_auto_smooth", text="Normals: Auto Smooth")
+ layout = self.layout
+ obj = context.object
+ obj_data = context.active_object.data
+ layout.separator()
+ layout.prop(obj_data, "use_auto_smooth", text="Normals: Auto Smooth")
- # Auto Smooth Angle - two tab spaces to align it with the rest of the menu
- layout.prop(obj_data, "auto_smooth_angle",
- text=" Auto Smooth Angle")
+ # Auto Smooth Angle - two tab spaces to align it with the rest of the menu
+ layout.prop(obj_data, "auto_smooth_angle",
+ text=" Auto Smooth Angle")
# List The Classes #
classes = (
- VIEW3D_MT_Edit_Multi,
- VIEW3D_MT_EditM_Edge,
- VIEW3D_OT_selecteditVertex,
- VIEW3D_OT_selecteditEdge,
- VIEW3D_OT_selecteditFace,
- VIEW3D_OT_selecteditVertsEdges,
- VIEW3D_OT_selecteditEdgesFaces,
- VIEW3D_OT_selecteditVertsFaces,
- VIEW3D_OT_selecteditVertsEdgesFaces,
+ VIEW3D_MT_Edit_Multi,
+ VIEW3D_MT_EditM_Edge,
+ VIEW3D_OT_selecteditVertex,
+ VIEW3D_OT_selecteditEdge,
+ VIEW3D_OT_selecteditFace,
+ VIEW3D_OT_selecteditVertsEdges,
+ VIEW3D_OT_selecteditEdgesFaces,
+ VIEW3D_OT_selecteditVertsFaces,
+ VIEW3D_OT_selecteditVertsEdgesFaces,
)
# Register Classes & Hotkeys #
def register():
- for cls in classes:
- bpy.utils.register_class(cls)
+ for cls in classes:
+ bpy.utils.register_class(cls)
- bpy.types.VIEW3D_MT_edit_mesh_normals.append(menu_func)
+ bpy.types.VIEW3D_MT_edit_mesh_normals.append(menu_func)
# Unregister Classes & Hotkeys #
def unregister():
- for cls in reversed(classes):
- bpy.utils.unregister_class(cls)
+ for cls in reversed(classes):
+ bpy.utils.unregister_class(cls)
- bpy.types.VIEW3D_MT_edit_mesh_normals.remove(menu_func)
+ bpy.types.VIEW3D_MT_edit_mesh_normals.remove(menu_func)
if __name__ == "__main__":
- register()
+ register()
diff --git a/space_view3d_spacebar_menu/snap_origin_cursor.py b/space_view3d_spacebar_menu/snap_origin_cursor.py
index f10f2dfc..b150a492 100644
--- a/space_view3d_spacebar_menu/snap_origin_cursor.py
+++ b/space_view3d_spacebar_menu/snap_origin_cursor.py
@@ -20,283 +20,283 @@
import bpy
from bpy.types import (
- Operator,
- Menu,
- )
+ Operator,
+ Menu,
+)
from bpy.props import (
- BoolProperty,
- StringProperty,
- )
+ BoolProperty,
+ StringProperty,
+)
from .object_menus import *
# ********** Object Snap Cursor **********
class VIEW3D_MT_Snap_Context(Menu):
- bl_label = "Snapping"
+ bl_label = "Snapping"
- def draw(self, context):
- layout = self.layout
- toolsettings = context.tool_settings
- layout.prop(toolsettings, "use_snap")
- layout.prop(toolsettings, "snap_elements", expand=True)
+ def draw(self, context):
+ layout = self.layout
+ toolsettings = context.tool_settings
+ layout.prop(toolsettings, "use_snap")
+ layout.prop(toolsettings, "snap_elements", expand=True)
class VIEW3D_MT_Snap_Origin(Menu):
- bl_label = "Snap Origin"
-
- def draw(self, context):
- layout = self.layout
- layout.operator_context = 'EXEC_AREA'
- layout.operator("object.origin_set",
- text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
- layout.separator()
- layout.operator("object.origin_set",
- text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
- layout.operator("object.origin_set",
- text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
- layout.operator("object.origin_set",
- text="Origin to Center of Mass").type = 'ORIGIN_CENTER_OF_MASS'
+ bl_label = "Snap Origin"
+
+ def draw(self, context):
+ layout = self.layout
+ layout.operator_context = 'EXEC_AREA'
+ layout.operator("object.origin_set",
+ text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
+ layout.separator()
+ layout.operator("object.origin_set",
+ text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
+ layout.operator("object.origin_set",
+ text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
+ layout.operator("object.origin_set",
+ text="Origin to Center of Mass").type = 'ORIGIN_CENTER_OF_MASS'
class VIEW3D_MT_CursorMenu(Menu):
- bl_label = "Snap To"
-
- def draw(self, context):
- layout = self.layout
- layout.operator_context = 'INVOKE_REGION_WIN'
- layout.menu("VIEW3D_MT_Snap_Origin")
- layout.menu("VIEW3D_MT_Snap_Context")
- layout.separator()
- layout.operator("view3d.snap_cursor_to_selected",
- text="Cursor to Selected")
- layout.operator("view3d.snap_cursor_to_center",
- text="Cursor to World Origin")
- layout.operator("view3d.snap_cursor_to_grid",
- text="Cursor to Grid")
- layout.operator("view3d.snap_cursor_to_active",
- text="Cursor to Active")
- layout.separator()
- layout.operator("view3d.snap_selected_to_cursor",
- text="Selection to Cursor").use_offset = False
- layout.operator("view3d.snap_selected_to_cursor",
- text="Selection to Cursor (Keep Offset)").use_offset = True
- layout.operator("view3d.snap_selected_to_grid",
- text="Selection to Grid")
- layout.operator("view3d.snap_cursor_selected_to_center",
- text="Selection and Cursor to World Origin")
+ bl_label = "Snap To"
+
+ def draw(self, context):
+ layout = self.layout
+ layout.operator_context = 'INVOKE_REGION_WIN'
+ layout.menu("VIEW3D_MT_Snap_Origin")
+ layout.menu("VIEW3D_MT_Snap_Context")
+ layout.separator()
+ layout.operator("view3d.snap_cursor_to_selected",
+ text="Cursor to Selected")
+ layout.operator("view3d.snap_cursor_to_center",
+ text="Cursor to World Origin")
+ layout.operator("view3d.snap_cursor_to_grid",
+ text="Cursor to Grid")
+ layout.operator("view3d.snap_cursor_to_active",
+ text="Cursor to Active")
+ layout.separator()
+ layout.operator("view3d.snap_selected_to_cursor",
+ text="Selection to Cursor").use_offset = False
+ layout.operator("view3d.snap_selected_to_cursor",
+ text="Selection to Cursor (Keep Offset)").use_offset = True
+ layout.operator("view3d.snap_selected_to_grid",
+ text="Selection to Grid")
+ layout.operator("view3d.snap_cursor_selected_to_center",
+ text="Selection and Cursor to World Origin")
class VIEW3D_MT_CursorMenuLite(Menu):
- bl_label = "Snap to"
-
- def draw(self, context):
- layout = self.layout
- layout.operator_context = 'INVOKE_REGION_WIN'
- layout.menu("VIEW3D_MT_Snap_Origin")
- layout.separator()
- layout.operator("view3d.snap_cursor_to_selected",
- text="Cursor to Selected")
- layout.operator("view3d.snap_cursor_to_center",
- text="Cursor to World Origin")
- layout.operator("view3d.snap_cursor_to_grid",
- text="Cursor to Grid")
- layout.operator("view3d.snap_cursor_to_active",
- text="Cursor to Active")
- layout.separator()
- layout.operator("view3d.snap_selected_to_cursor",
- text="Selection to Cursor").use_offset = False
- layout.operator("view3d.snap_selected_to_cursor",
- text="Selection to Cursor (Keep Offset)").use_offset = True
- layout.operator("view3d.snap_selected_to_grid",
- text="Selection to Grid")
- layout.operator("view3d.snap_cursor_selected_to_center",
- text="Selection and Cursor to World Origin")
+ bl_label = "Snap to"
+
+ def draw(self, context):
+ layout = self.layout
+ layout.operator_context = 'INVOKE_REGION_WIN'
+ layout.menu("VIEW3D_MT_Snap_Origin")
+ layout.separator()
+ layout.operator("view3d.snap_cursor_to_selected",
+ text="Cursor to Selected")
+ layout.operator("view3d.snap_cursor_to_center",
+ text="Cursor to World Origin")
+ layout.operator("view3d.snap_cursor_to_grid",
+ text="Cursor to Grid")
+ layout.operator("view3d.snap_cursor_to_active",
+ text="Cursor to Active")
+ layout.separator()
+ layout.operator("view3d.snap_selected_to_cursor",
+ text="Selection to Cursor").use_offset = False
+ layout.operator("view3d.snap_selected_to_cursor",
+ text="Selection to Cursor (Keep Offset)").use_offset = True
+ layout.operator("view3d.snap_selected_to_grid",
+ text="Selection to Grid")
+ layout.operator("view3d.snap_cursor_selected_to_center",
+ text="Selection and Cursor to World Origin")
# Code thanks to Isaac Weaver (wisaac) D1963
class VIEW3D_OT_SnapCursSelToCenter(Operator):
- bl_idname = "view3d.snap_cursor_selected_to_center"
- bl_label = "Snap Cursor & Selection to World Origin"
- bl_description = ("Snap 3D cursor and selected objects to the center \n"
- "Works only in Object Mode")
+ bl_idname = "view3d.snap_cursor_selected_to_center"
+ bl_label = "Snap Cursor & Selection to World Origin"
+ bl_description = ("Snap 3D cursor and selected objects to the center \n"
+ "Works only in Object Mode")
- @classmethod
- def poll(cls, context):
- return (context.area.type == "VIEW_3D" and context.mode == "OBJECT")
+ @classmethod
+ def poll(cls, context):
+ return (context.area.type == "VIEW_3D" and context.mode == "OBJECT")
- def execute(self, context):
- context.scene.cursor.location = (0, 0, 0)
- for obj in context.selected_objects:
- obj.location = (0, 0, 0)
- return {'FINISHED'}
+ def execute(self, context):
+ context.scene.cursor.location = (0, 0, 0)
+ for obj in context.selected_objects:
+ obj.location = (0, 0, 0)
+ return {'FINISHED'}
# Cursor Edge Intersection Defs #
def abs(val):
- if val > 0:
- return val
- return -val
+ if val > 0:
+ return val
+ return -val
def edgeIntersect(context, operator):
- from mathutils.geometry import intersect_line_line
+ from mathutils.geometry import intersect_line_line
- obj = context.active_object
+ obj = context.active_object
- if (obj.type != "MESH"):
- operator.report({'ERROR'}, "Object must be a mesh")
- return None
+ if (obj.type != "MESH"):
+ operator.report({'ERROR'}, "Object must be a mesh")
+ return None
- edges = []
- mesh = obj.data
- verts = mesh.vertices
+ edges = []
+ mesh = obj.data
+ verts = mesh.vertices
- is_editmode = (obj.mode == 'EDIT')
- if is_editmode:
- bpy.ops.object.mode_set(mode='OBJECT')
+ is_editmode = (obj.mode == 'EDIT')
+ if is_editmode:
+ bpy.ops.object.mode_set(mode='OBJECT')
- for e in mesh.edges:
- if e.select:
- edges.append(e)
+ for e in mesh.edges:
+ if e.select:
+ edges.append(e)
- if len(edges) > 2:
- break
+ if len(edges) > 2:
+ break
- if is_editmode:
- bpy.ops.object.mode_set(mode='EDIT')
+ if is_editmode:
+ bpy.ops.object.mode_set(mode='EDIT')
- if len(edges) != 2:
- operator.report({'ERROR'},
- "Operator requires exactly 2 edges to be selected")
- return
+ if len(edges) != 2:
+ operator.report({'ERROR'},
+ "Operator requires exactly 2 edges to be selected")
+ return
- line = intersect_line_line(verts[edges[0].vertices[0]].co,
- verts[edges[0].vertices[1]].co,
- verts[edges[1].vertices[0]].co,
- verts[edges[1].vertices[1]].co)
+ line = intersect_line_line(verts[edges[0].vertices[0]].co,
+ verts[edges[0].vertices[1]].co,
+ verts[edges[1].vertices[0]].co,
+ verts[edges[1].vertices[1]].co)
- if line is None:
- operator.report({'ERROR'}, "Selected edges do not intersect")
- return
+ if line is None:
+ operator.report({'ERROR'}, "Selected edges do not intersect")
+ return
- point = line[0].lerp(line[1], 0.5)
- context.scene.cursor.location = obj.matrix_world @ point
+ point = line[0].lerp(line[1], 0.5)
+ context.scene.cursor.location = obj.matrix_world @ point
# Cursor Edge Intersection Operator #
class VIEW3D_OT_CursorToEdgeIntersection(Operator):
- bl_idname = "view3d.snap_cursor_to_edge_intersection"
- bl_label = "Cursor to Edge Intersection"
- bl_description = "Finds the mid-point of the shortest distance between two edges"
+ bl_idname = "view3d.snap_cursor_to_edge_intersection"
+ bl_label = "Cursor to Edge Intersection"
+ bl_description = "Finds the mid-point of the shortest distance between two edges"
- @classmethod
- def poll(cls, context):
- obj = context.active_object
- return (obj is not None and obj.type == 'MESH')
+ @classmethod
+ def poll(cls, context):
+ obj = context.active_object
+ return (obj is not None and obj.type == 'MESH')
- def execute(self, context):
- # Prevent unsupported Execution in Local View modes
- space = bpy.context.space_data
- if space.local_view:
- self.report({'INFO'}, 'Global Perspective modes only unable to continue.')
- return {'FINISHED'}
- edgeIntersect(context, self)
- return {'FINISHED'}
+ def execute(self, context):
+ # Prevent unsupported Execution in Local View modes
+ space = bpy.context.space_data
+ if space.local_view:
+ self.report({'INFO'}, 'Global Perspective modes only unable to continue.')
+ return {'FINISHED'}
+ edgeIntersect(context, self)
+ return {'FINISHED'}
# Origin To Selected Edit Mode #
def vfeOrigin(context):
- try:
- cursorPositionX = context.scene.cursor.location[0]
- cursorPositionY = context.scene.cursor.location[1]
- cursorPositionZ = context.scene.cursor.location[2]
- bpy.ops.view3d.snap_cursor_to_selected()
- bpy.ops.object.mode_set()
- bpy.ops.object.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')
- bpy.ops.object.mode_set(mode='EDIT')
- context.scene.cursor.location[0] = cursorPositionX
- context.scene.cursor.location[1] = cursorPositionY
- context.scene.cursor.location[2] = cursorPositionZ
- return True
- except:
- return False
+ try:
+ cursorPositionX = context.scene.cursor.location[0]
+ cursorPositionY = context.scene.cursor.location[1]
+ cursorPositionZ = context.scene.cursor.location[2]
+ bpy.ops.view3d.snap_cursor_to_selected()
+ bpy.ops.object.mode_set()
+ bpy.ops.object.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')
+ bpy.ops.object.mode_set(mode='EDIT')
+ context.scene.cursor.location[0] = cursorPositionX
+ context.scene.cursor.location[1] = cursorPositionY
+ context.scene.cursor.location[2] = cursorPositionZ
+ return True
+ except:
+ return False
class VIEW3D_OT_SetOriginToSelected(Operator):
- bl_idname = "object.setorigintoselected"
- bl_label = "Set Origin to Selected"
- bl_description = "Set Origin to Selected"
+ bl_idname = "object.setorigintoselected"
+ bl_label = "Set Origin to Selected"
+ bl_description = "Set Origin to Selected"
- @classmethod
- def poll(cls, context):
- return (context.area.type == "VIEW_3D" and context.active_object is not None)
+ @classmethod
+ def poll(cls, context):
+ return (context.area.type == "VIEW_3D" and context.active_object is not None)
- def execute(self, context):
- check = vfeOrigin(context)
- if not check:
- self.report({"ERROR"}, "Set Origin to Selected could not be performed")
- return {'CANCELLED'}
+ def execute(self, context):
+ check = vfeOrigin(context)
+ if not check:
+ self.report({"ERROR"}, "Set Origin to Selected could not be performed")
+ return {'CANCELLED'}
- return {'FINISHED'}
+ return {'FINISHED'}
# ********** Edit Mesh Cursor **********
class VIEW3D_MT_EditCursorMenu(Menu):
- bl_label = "Snap To"
-
- def draw(self, context):
- layout = self.layout
- layout.operator_context = 'INVOKE_REGION_WIN'
- layout.operator("object.setorigintoselected",
- text="Origin to Selected V/F/E")
- layout.separator()
- layout.menu("VIEW3D_MT_Snap_Origin")
- layout.menu("VIEW3D_MT_Snap_Context")
- layout.separator()
- layout.operator("view3d.snap_cursor_to_selected",
- text="Cursor to Selected")
- layout.operator("view3d.snap_cursor_to_center",
- text="Cursor to World Origin")
- layout.operator("view3d.snap_cursor_to_grid",
- text="Cursor to Grid")
- layout.operator("view3d.snap_cursor_to_active",
- text="Cursor to Active")
- layout.operator("view3d.snap_cursor_to_edge_intersection",
- text="Cursor to Edge Intersection")
- layout.separator()
- layout.operator("view3d.snap_selected_to_cursor",
- text="Selection to Cursor").use_offset = False
- layout.operator("view3d.snap_selected_to_cursor",
- text="Selection to Cursor (Keep Offset)").use_offset = True
- layout.operator("view3d.snap_selected_to_grid",
- text="Selection to Grid")
+ bl_label = "Snap To"
+
+ def draw(self, context):
+ layout = self.layout
+ layout.operator_context = 'INVOKE_REGION_WIN'
+ layout.operator("object.setorigintoselected",
+ text="Origin to Selected V/F/E")
+ layout.separator()
+ layout.menu("VIEW3D_MT_Snap_Origin")
+ layout.menu("VIEW3D_MT_Snap_Context")
+ layout.separator()
+ layout.operator("view3d.snap_cursor_to_selected",
+ text="Cursor to Selected")
+ layout.operator("view3d.snap_cursor_to_center",
+ text="Cursor to World Origin")
+ layout.operator("view3d.snap_cursor_to_grid",
+ text="Cursor to Grid")
+ layout.operator("view3d.snap_cursor_to_active",
+ text="Cursor to Active")
+ layout.operator("view3d.snap_cursor_to_edge_intersection",
+ text="Cursor to Edge Intersection")
+ layout.separator()
+ layout.operator("view3d.snap_selected_to_cursor",
+ text="Selection to Cursor").use_offset = False
+ layout.operator("view3d.snap_selected_to_cursor",
+ text="Selection to Cursor (Keep Offset)").use_offset = True
+ layout.operator("view3d.snap_selected_to_grid",
+ text="Selection to Grid")
# List The Classes #
classes = (
- VIEW3D_MT_CursorMenu,
- VIEW3D_MT_CursorMenuLite,
- VIEW3D_MT_Snap_Context,
- VIEW3D_MT_Snap_Origin,
- VIEW3D_OT_SnapCursSelToCenter,
- VIEW3D_OT_CursorToEdgeIntersection,
- VIEW3D_OT_SetOriginToSelected,
- VIEW3D_MT_EditCursorMenu,
+ VIEW3D_MT_CursorMenu,
+ VIEW3D_MT_CursorMenuLite,
+ VIEW3D_MT_Snap_Context,
+ VIEW3D_MT_Snap_Origin,
+ VIEW3D_OT_SnapCursSelToCenter,
+ VIEW3D_OT_CursorToEdgeIntersection,
+ VIEW3D_OT_SetOriginToSelected,
+ VIEW3D_MT_EditCursorMenu,
)
# Register Classes & Hotkeys #
def register():
- for cls in classes:
- bpy.utils.register_class(cls)
+ for cls in classes:
+ bpy.utils.register_class(cls)
# Unregister Classes & Hotkeys #
def unregister():
- for cls in reversed(classes):
- bpy.utils.unregister_class(cls)
+ for cls in reversed(classes):
+ bpy.utils.unregister_class(cls)
if __name__ == "__main__":
- register()
+ register()