Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert selected strips to assets via sound, image or clip IDs.
# Convert selected strips to assets via sound, image or clip IDs.
# By tintwotin & batFINGER
import bpy, os
strips = bpy.context.selected_editable_sequences
strips = sorted(strips, key=lambda strip: strip.frame_final_start)
for sq in strips:
if sq.type == "SOUND":
sound_path = bpy.path.abspath(sq.sound.filepath)
my_sound = bpy.data.sounds.load(sound_path)
print("Sound Path: "+sound_path)
bpy.ops.asset.mark({"id": my_sound})
if sq.type == "IMAGE":
strip_dirname = os.path.dirname(sq.directory)
image_path = bpy.path.abspath(os.path.join(strip_dirname, sq.name))
my_image = bpy.data.images.load(image_path)
print("Image Path: "+image_path)
bpy.ops.asset.mark({"id": my_image})
if sq.type == "MOVIE":
strip_dirname = (os.path.dirname(sq.filepath))
strip_path = bpy.path.abspath(os.path.join(strip_dirname, sq.name))
my_movie = bpy.data.movieclips.load(strip_path)
print("Movie Path: "+strip_path)
bpy.ops.asset.mark({"id": my_movie})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment