Skip to content

Instantly share code, notes, and snippets.

@tin2tin
Last active November 1, 2022 05:02
Show Gist options
  • Save tin2tin/0da859896432245fd15cfe960fdd9ee9 to your computer and use it in GitHub Desktop.
Save tin2tin/0da859896432245fd15cfe960fdd9ee9 to your computer and use it in GitHub Desktop.
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