Newer
Older
#3d_cursor_menu.py (c) 2010 Jonathan Smith (JayDez)
#Original Script by: Mariano Hidalgo (uselessdreamer)
#contributed to by: Crouch
#
#Tested with r27424
#
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
bl_addon_info = {
'name': '3d View: Cursor Menu',
'author': 'JayDez',
'version': '2.4',
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
'location': 'View3D > Mouse > Menu ',
'url': 'http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/3d_Cursor_Menu',
'category': '3d View'}
"""
Name: '3D Cursor Menu'
Blender: 250
Group: 'View3D'
"""
__author__ = ["Jonathan Smith (JayDez)"]
__version__ = '2.3'
__url__ = ["http://blenderartists.org/forum/showthread.php?p=1589350"]
__bpydoc__= """
3D Cursor Menu
This adds a 3D Cursor Menu in the 3DView.
Usage:
Enable in "user preferences>addons>3d_cursor_menu".
Right click in an empty space in the 3D View(that means nothing
selectable is there). If your select mouse is set to left then left
click in the 3D View.
Choose your function from the menu.
Version history:
v2.42 = (JayDez) - Added url for tech support.
v2.41 - (JayDez) - Cleaned up bpydoc, added underscores in the name.
v2.4 - (JayDez) - Added bpydoc as well as changing to click only
(instead of double click).
v2.3 - (JayDez) - Added revert_pivot() which allows you to change
pivot point back to normal(which right now is median point).
v2.2 - (Crouch) - Fix in register function, fix with random quotation
mark which crashed script.
v2.1 - (Crouch) - added unregister() and set pivot point to cursor.
v2.0 - (JayDez) - 2.5 script (initial revision)
v1.0 - Original 2.49 script
"""
import bpy
from bpy import *
class pivot_cursor(bpy.types.Operator):
bl_idname = "view3d.pivot_cursor"
bl_label = "Cursor as Pivot Point"
def poll(self, context):
return bpy.context.space_data.pivot_point != 'CURSOR'
def execute(self, context):
bpy.context.space_data.pivot_point = 'CURSOR'
return {'FINISHED'}
class revert_pivot(bpy.types.Operator):
bl_idname = "view3d.revert_pivot"
bl_label = "Reverts Pivot Point to median"
def poll(self, context):
return bpy.context.space_data.pivot_point != 'MEDIAN_POINT'
def execute(self, context):
bpy.context.space_data.pivot_point = 'MEDIAN_POINT'
#change this to 'BOUDNING_BOX_CENTER' if needed...
return{'FINISHED'}
class VIEW3D_MT_3D_Cursor_Menu(bpy.types.Menu):
bl_label = "3D Cursor Menu"
def draw(self, context):
layout = self.layout
layout.operator("view3d.snap_cursor_to_center", text="Snap Cursor to Center")
layout.operator("view3d.snap_cursor_to_grid", text="Snap Cursor to Grid")
layout.operator("view3d.snap_cursor_to_selected", text="Snap Cursor to Selected")
layout.operator("view3d.snap_selected_to_cursor", text="Snap Selected to Cursor")
layout.separator()
layout.operator("view3d.pivot_cursor", text="Set Cursor as Pivot Point")
layout.operator("view3d.revert_pivot", text="Revert Pivot Point")
def register():
bpy.types.register(VIEW3D_MT_3D_Cursor_Menu)
bpy.types.register(pivot_cursor)
bpy.types.register(revert_pivot)
km = bpy.context.manager.active_keyconfig.keymaps['3D View']
kmi = km.add_item('wm.call_menu', 'SELECTMOUSE', 'CLICK')
kmi.properties.name = "VIEW3D_MT_3D_Cursor_Menu"
def unregister():
bpy.types.unregister(VIEW3D_MT_3D_Cursor_Menu)
bpy.types.unregister(pivot_cursor)
bpy.types.unregister(revert_pivot)
km = bpy.context.manager.active_keyconfig.keymaps['3D View']
for kmi in km.items:
if kmi.idname == 'wm.call_menu':
if kmi.properties.name == "VIEW3D_MT_3D_Cursor_Menu":
km.remove_item(kmi)
break
if __name__ == "__main__":
register()