Hey, I need to exclude some animations from importing from a .blend file
I must not delete them from the .blend as I use them as source for the final animations
Only the ones I want are in the NLA, but godot imports everything anyways
Im using GameRigTools, that means I have 2 skeletons, one with Rigify and a simples one, the only one Im importing is the simple skeleton, that part is working correctly
I`m sure the NLA tracks for the other skeleton is empty
The “-noimp” tag does not work with animations unfortunately
I tryed a post-import script, but it seems I dont have access to the animations in order to delete them
There is no checkbox to skip import in individual animations as there is in the skeleton
@tool
extends EditorScenePostImport
const REMOVE_ANIMATION_REGEX: String = "-noimp$"
func _post_import(scene: Node) -> Node:
cleanup_animations(scene)
return scene
func cleanup_animations(scene: Node) -> void:
var anim_player := scene.find_child("AnimationPlayer", true, true) as AnimationPlayer
if not anim_player: return
var remove_regex = RegEx.new()
remove_regex.compile(REMOVE_ANIMATION_REGEX)
var mixer := anim_player as AnimationMixer
var lib_names = mixer.get_animation_library_list()
for lib_name in lib_names:
var anim_lib: AnimationLibrary = mixer.get_animation_library(lib_name)
if not anim_lib: continue
for anim_name in anim_lib.get_animation_list():
if remove_regex.search(anim_name):
anim_lib.remove_animation(anim_name)
Very useful, thanks! I got some support animations I use only on Blender but they get exported to Godot as well. I made some adjustments to the script:
@tool
extends EditorScenePostImport
# Constants
const PREFIX := "_"
const SUFFIX := "-noimp"
# Built-in overrides
func _post_import(scene: Node) -> Node:
_cleanup_animations(scene)
return scene
# Private methods
func _cleanup_animations(scene: Node) -> void:
var anim_player := scene.find_child("AnimationPlayer") as AnimationPlayer
if not anim_player:
return
var lib_names = anim_player.get_animation_library_list()
for lib_name in lib_names:
var anim_lib := anim_player.get_animation_library(lib_name)
if not anim_lib:
continue
for anim_name in anim_lib.get_animation_list():
if anim_name.begins_with(PREFIX) or anim_name.ends_with(SUFFIX):
anim_lib.remove_animation(anim_name)