Hi
Could somebody write part of script which add my script to menu? I mean I want my script here:
Here is my code, it serves to mirror the animation:
bl_info = {
"name": "Mirror animation",
"author": "Gal anonim",
"version": (1,0),
"blender": (2, 6, 6),
"location": "???",
"description": "Mirror animation",
"warning": "",
"wiki_url": "none",
"tracker_url": "none",
"category": "UV"}
####################################################
import bpy
start_frame=0
end_frame=18
class AnimationMirror(bpy.types.Operator):
''''''
bl_idname = "animation_mirror"
bl_label = "Mirror animation"
bl_description = "Mirror animation - select all the bones"
bl_options = {'REGISTER', 'UNDO'}
def set_frame(sf):
bpy.context.scene.frame_set(frame=sf)
bpy.context.active_object.update(scene=bpy.context.scene)
bpy.context.scene.update()
## execute
def execute(self, context):
#print("------START------")
each_frame=start_frame
while each_frame<=end_frame:
set_frame(sf=each_frame)
bpy.ops.pose.copy()
set_frame(sf=each_frame+(end_frame-start_frame))
bpy.ops.pose.paste(flipped=True)
print('copying '+str(each_frame)+' to '+str(bpy.context.scene.frame_current))
bpy.ops.anim.keyframe_insert()
if each_frame==end_frame:
break
set_frame(sf=each_frame)
bpy.ops.screen.keyframe_jump(next=True)
each_frame=bpy.context.scene.frame_current
#print("-------END-------")
return {'FINISHED'}
#################################################
#### REGISTER ###################################
#################################################
def add_to_menu(self, context) :
self.layout.operator("mirror animation")
self.layout.operator("mirror animation")
def register():
bpy.utils.register_module(__name__)
bpy.types.????.append(add_to_menu) #based on some example I suppose that instead of ??? I need some id of pose menu
def unregister():
bpy.utils.unregister_module(__name__)
bpy.types.?????.remove(add_to_menu)
if __name__ == "__main__":
register()
If additionally somebody know how to make variable ‘start_frame’ and ‘end_frame’ as dynamically changes in blender API then I would be grateful for help. However the most important for me is how to add this script to menu.