Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Import and select a sound strip in the sequencer
import bpy
# Import and select a sound strip in the sequencer, then run scipt.
# A speaker object and a sound data-block will be created and linked.
active = bpy.context.scene.sequence_editor.active_strip
if active and active.type == "SOUND":
path = bpy.path.abspath(active.sound.filepath)
bpy.ops.object.speaker_add()
speaker = bpy.context.object
speaker.data.sound = bpy.data.sounds.load(path)
speaker.data.update_tag()
bpy.context.collection.objects.unlink(speaker)
bpy.context.collection.objects.link(speaker)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment