MeshLibrary import with GDScript

Godot Version

4.2

Question

I try to create a MeshLibrary with GDScript from a Blender file. So using a EditorScenePostImport script, I create a new MeshLibrary, add the meshes and save it. The script is executed without erros, but unfortunatelly the MeshLibrary seems still be empty, when I add it to a grid.

What is wrong in my script?

@tool # Needed so it runs in editor.
extends EditorScenePostImport

# This sample changes all node names.
# Called right after the scene is imported and gets the root node.
func _post_import(scene):
	var source = get_source_file()
	print_rich("Processing import for scene '" + scene.name + "' from '" + source + "'")
	var meshLib = MeshLibrary.new()
	var dest = source.replace('.blend', '.tres')
	print("Creating new MeshLibrary '" + dest + "'")
	iterate(scene, meshLib)
	var err = ResourceSaver.save(meshLib, dest)
	if err != OK:
		printerr("Error saving MeshLibrary: " + str(err))
	else:
		print("Saved MeshLibrary: " + dest)
	return scene

func iterate(node, meshLib):
	if node != null:
		if node.get_class() == "MeshInstance3D":
			add_mesh(node, meshLib)
		for child in node.get_children():
			iterate(child, meshLib)

func add_mesh(node, meshLib):
	var index = meshLib.get_last_unused_item_id()
	print_rich("Import Mesh: [b]%s[/b] at %d" % [node.name, index])
	meshLib.create_item(index)
	meshLib.set_item_name(index, node.name)
	meshLib.set_item_mesh(index, node.get_mesh())