Add keymaps, specials menu and auto center view checkbox #3
19
__init__.py
19
__init__.py
@ -41,11 +41,13 @@ class C3DB_OT_restore(bpy.types.Operator):
|
||||
item = context.scene.C3DB_3Dcursors_collection[context.scene.C3DB_3Dcursors_index]
|
||||
context.scene.cursor.location = item.location
|
||||
context.scene.cursor.rotation_euler = item.rotation
|
||||
if context.scene.c3db_auto_center_view_checkbox:
|
||||
bpy.ops.view3d.view_center_cursor()
|
||||
context.area.tag_redraw() # Add this line to refresh the UI
|
||||
return {'FINISHED'}
|
||||
|
||||
class C3DB_OT_restore_and_next(bpy.types.Operator):
|
||||
"""Restore selected 3D Cursor and select next one in the list"""
|
||||
"""Restore selected 3D Cursor and go to next one in the list"""
|
||||
bl_idname = "c3db.restore_and_next"
|
||||
bl_label = "Load & next"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
@ -58,6 +60,8 @@ class C3DB_OT_restore_and_next(bpy.types.Operator):
|
||||
item = context.scene.C3DB_3Dcursors_collection[context.scene.C3DB_3Dcursors_index]
|
||||
context.scene.cursor.location = item.location
|
||||
context.scene.cursor.rotation_euler = item.rotation
|
||||
if context.scene.c3db_auto_center_view_checkbox:
|
||||
bpy.ops.view3d.view_center_cursor()
|
||||
# Select the next valid 3D cursor in the list
|
||||
C3DB_3Dcursors_collection = context.scene.C3DB_3Dcursors_collection
|
||||
C3DB_3Dcursors_index = context.scene.C3DB_3Dcursors_index
|
||||
@ -69,7 +73,7 @@ class C3DB_OT_restore_and_next(bpy.types.Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
class C3DB_OT_restore_and_previous(bpy.types.Operator):
|
||||
"""Restore selected 3D Cursor and select previous one in the list"""
|
||||
"""Restore selected 3D Cursor and go to previous one in the list"""
|
||||
bl_idname = "c3db.restore_and_previous"
|
||||
bl_label = "Load & previous"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
@ -83,6 +87,8 @@ class C3DB_OT_restore_and_previous(bpy.types.Operator):
|
||||
item = context.scene.C3DB_3Dcursors_collection[context.scene.C3DB_3Dcursors_index]
|
||||
context.scene.cursor.location = item.location
|
||||
context.scene.cursor.rotation_euler = item.rotation
|
||||
if context.scene.c3db_auto_center_view_checkbox:
|
||||
bpy.ops.view3d.view_center_cursor()
|
||||
# Select the previous valid 3D cursor in the list
|
||||
C3DB_3Dcursors_collection = context.scene.C3DB_3Dcursors_collection
|
||||
C3DB_3Dcursors_index = context.scene.C3DB_3Dcursors_index
|
||||
@ -174,6 +180,7 @@ class C3DB_PT_panel(bpy.types.Panel):
|
||||
row = layout.row()
|
||||
row.operator("c3db.restore")
|
||||
row.operator("view3d.view_center_cursor", text="Center View")
|
||||
row.prop(context.scene, "c3db_auto_center_view_checkbox")
|
||||
row = layout.row()
|
||||
row.operator("c3db.restore_and_next")
|
||||
row = layout.row()
|
||||
@ -189,6 +196,12 @@ def register():
|
||||
bpy.types.Scene.C3DB_3Dcursors_collection = bpy.props.CollectionProperty(type=C3DB_PG_properties)
|
||||
bpy.types.Scene.C3DB_3Dcursors_index = bpy.props.IntProperty()
|
||||
|
||||
bpy.types.Scene.c3db_auto_center_view_checkbox = bpy.props.BoolProperty(
|
||||
name="",
|
||||
description="Auto center view on load",
|
||||
default=False
|
||||
)
|
||||
|
||||
wm = bpy.context.window_manager
|
||||
km = wm.keyconfigs.addon.keymaps.new(name='3D View', space_type='VIEW_3D')
|
||||
|
||||
@ -213,6 +226,8 @@ def unregister():
|
||||
del bpy.types.Scene.C3DB_3Dcursors_collection
|
||||
del bpy.types.Scene.C3DB_3Dcursors_index
|
||||
|
||||
del bpy.types.Scene.c3db_auto_center_view_checkbox
|
||||
|
||||
wm = bpy.context.window_manager
|
||||
for km, kmi in c3db_keymaps:
|
||||
km.keymap_items.remove(kmi)
|
||||
|
Loading…
Reference in New Issue
Block a user