Created
January 16, 2025 14:55
-
-
Save catprisbrey/202c3b7fa5da813cf8f15bc5a36b6b9a to your computer and use it in GitHub Desktop.
Blender to Godot - Add all NLA Tracks and strips
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
## Sometimes you add a LOT of NLA aniamtions to your blend file and want to add them to your model fast. | |
## OR you hate your animations being out of order, just remove them and re-add them for some quick | |
## alphabatising. | |
# Get the current object with an animation | |
obj = bpy.context.object | |
# Ensure the object has animation data | |
if obj.animation_data is None: | |
obj.animation_data_create() | |
# Loop through all actions in the blend file | |
for action in bpy.data.actions: | |
# Create a new NLA track | |
nla_track = obj.animation_data.nla_tracks.new() | |
# Set the name of the NLA track to match the action name | |
nla_track.name = action.name | |
# Convert frame range to integers | |
start_frame = int(action.frame_range[0]) | |
end_frame = int(action.frame_range[1]) | |
# Create a new NLA strip in the track and assign the action to it | |
nla_strip = nla_track.strips.new(action.name, start_frame, action) | |
# Adjust the strip to fit the action's frame range | |
nla_strip.frame_end = end_frame |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment