92 lines
2.8 KiB
Python
92 lines
2.8 KiB
Python
import bpy
|
|
from .utils import parse_scene_objects, parse_object, release_object, recompute, unregister_existing_handler, register_handler
|
|
|
|
##############################################################
|
|
|
|
class OBJECT_OT_parse_scene_objects(bpy.types.Operator):
|
|
"""Collect control ranges for all objects in the scene"""
|
|
bl_idname = "object.parse_scene_objects"
|
|
bl_label = "Collect Control Ranges"
|
|
bl_options = {'REGISTER', 'UNDO'}
|
|
|
|
def execute(self, context):
|
|
parse_scene_objects()
|
|
return {'FINISHED'}
|
|
|
|
|
|
class OBJECT_OT_parse_object(bpy.types.Operator):
|
|
"""Parse the active object"""
|
|
bl_idname = "object.parse_object"
|
|
bl_label = "Parse Object"
|
|
bl_options = {'REGISTER', 'UNDO'}
|
|
|
|
def execute(self, context):
|
|
obj = context.active_object
|
|
if obj:
|
|
parse_object(obj)
|
|
return {'FINISHED'}
|
|
else:
|
|
self.report({'WARNING'}, "No active object to parse")
|
|
return {'CANCELLED'}
|
|
|
|
|
|
class OBJECT_OT_release_object(bpy.types.Operator):
|
|
"""Release the active object"""
|
|
bl_idname = "object.release_object"
|
|
bl_label = "Release Object"
|
|
bl_options = {'REGISTER', 'UNDO'}
|
|
|
|
def execute(self, context):
|
|
obj = context.active_object
|
|
if obj:
|
|
release_object(obj)
|
|
return {'FINISHED'}
|
|
else:
|
|
self.report({'WARNING'}, "No active object to release")
|
|
return {'CANCELLED'}
|
|
|
|
|
|
class OBJECT_PT_control_tools(bpy.types.Panel):
|
|
"""Panel for Control Tools"""
|
|
bl_label = "Control Tools"
|
|
bl_idname = "OBJECT_PT_control_tools"
|
|
bl_space_type = 'PROPERTIES'
|
|
bl_region_type = 'WINDOW'
|
|
bl_context = "object"
|
|
|
|
def draw(self, context):
|
|
layout = self.layout
|
|
layout.label(text="All Objects:")
|
|
layout.operator("object.parse_scene_objects", text="Parse All Objects")
|
|
|
|
layout.separator()
|
|
layout.label(text="Active Object:")
|
|
layout.operator("object.parse_object", text="Parse Object")
|
|
layout.operator("object.release_object", text="Release Object")
|
|
|
|
|
|
##############################################################
|
|
|
|
# Registration
|
|
|
|
def execute():
|
|
parse_scene_objects()
|
|
recompute()
|
|
|
|
def register():
|
|
unregister_existing_handler()
|
|
register_handler()
|
|
|
|
bpy.utils.register_class(OBJECT_OT_parse_scene_objects)
|
|
bpy.utils.register_class(OBJECT_OT_parse_object)
|
|
bpy.utils.register_class(OBJECT_OT_release_object)
|
|
bpy.utils.register_class(OBJECT_PT_control_tools) # Register panel
|
|
|
|
def unregister():
|
|
|
|
unregister_existing_handler()
|
|
bpy.utils.unregister_class(OBJECT_OT_parse_scene_objects)
|
|
bpy.utils.unregister_class(OBJECT_OT_parse_object)
|
|
bpy.utils.unregister_class(OBJECT_OT_release_object)
|
|
bpy.utils.unregister_class(OBJECT_PT_control_tools) # Register panel
|