Maybe something like this:
import bpy
class SimpleOperator(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.simple_operator"
bl_label = "Simple Object Operator"
action_name = bpy.props.StringProperty(name="Action")
def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self)
def draw(self, context):
self.layout.prop_search(self, "action_name", bpy.data, "actions")
def execute(self, context):
self.report({'INFO'}, self.action_name)
scene = context.scene
action = bpy.data.actions.get(self.action_name)
if action is None:
return {'CANCELLED'}
for ob in context.selected_editable_objects:
if ob.type != 'MESH':
continue
if ob.animation_data is None:
ob.animation_data_create()
tracks = ob.animation_data.nla_tracks
track = tracks.new()
track.strips.new(action.name, scene.frame_current, action)
return {'FINISHED'}
def register():
bpy.utils.register_class(SimpleOperator)
def unregister():
bpy.utils.unregister_class(SimpleOperator)
if __name__ == "__main__":
register()
# test call (with CubeAction pre-selected
bpy.ops.object.simple_operator('INVOKE_DEFAULT', action_name="CubeAction")