Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# ##### 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_info = {
"name": "Shot Utilities",
"description": "",
"author": "p2or",
"version": (0, 1),
"blender": (2, 70, 0),
"location": "Timeline",
"warning": "", # used for warning icon and text in addons panel
"wiki_url": "",
"tracker_url": "",
"category": "Animation"
}
import bpy
class SHOTUTILS_preferences(bpy.types.AddonPreferences):
bl_idname = __name__
start = bpy.props.IntProperty(
name="Start Frame",
description="Custom start frame",
default=1001)
end = bpy.props.IntProperty(
name="End Frame",
description="Custom end frame",
default=1241)
def draw(self, context):
layout = self.layout
row = layout.row(align=True)
row.prop(self, "start")
row.prop(self, "end")
row = layout.row()
row.operator(SHOTUTILS_OT_resetPreferences.bl_idname)
class SHOTUTILS_OT_resetPreferences(bpy.types.Operator):
bl_idname = "timeline_utils.reset_preferences"
bl_label = "Reset Preferences"
bl_options = {"INTERNAL"}
def execute(self, context):
prefs = context.user_preferences.addons[__name__].preferences
prefs.property_unset("start")
prefs.property_unset("end")
return {'FINISHED'}
class SHOTUTILS_OT_range(bpy.types.Operator):
bl_idname = "screen.shot_range"
bl_label = "Shot Range"
bl_description = "Set Shot Range"
bl_options = {'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'TIMELINE'
def execute(self, context):
prefs = context.user_preferences.addons[__name__].preferences
context.scene.frame_start = prefs.start
context.scene.frame_end = prefs.end
context.scene.frame_current = prefs.start
bpy.ops.time.view_all()
return{'FINISHED'}
def draw_shotutils(self, context):
scene = context.scene
prefs = context.user_preferences.addons[__name__].preferences
layout = self.layout
row = layout.row(align=True)
row.operator(SHOTUTILS_OT_range.bl_idname, icon="CAMERA_DATA")
def register():
bpy.utils.register_class(SHOTUTILS_preferences)
bpy.utils.register_class(SHOTUTILS_OT_resetPreferences)
bpy.utils.register_class(SHOTUTILS_OT_range)
bpy.types.TIME_HT_header.append(draw_shotutils)
def unregister():
bpy.types.INFO_HT_header.remove(draw_shotutils)
bpy.utils.unregister_class(SHOTUTILS_OT_range)
bpy.utils.unregister_class(SHOTUTILS_OT_resetPreferences)
bpy.utils.unregister_class(SHOTUTILS_preferences)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.