I am trying to do the following using the Python API:
- import an armature from an fbx file
- add it to the asset browser
- delete the armature from the scene, but not from the file, so that I can keep it in the Asset Browser
Fbx import is working nicely and so is adding it to the asset browser. However, when I try to delete the armature from the scene, I only found a way to delete it from the file entirely, which of course removes the armature from the Asset Browser.
However, I noticed that when I don't delete the armature via Python but via right-click on the object in the outliner and then select "delete hierarchy" this fulfills my requirements: The armature is gone from the scene, but it remains in the Asset Browser.
When I manually select Delete instead of Delete hierarchy, the armature is deleted completely from the file as it also happens in my Python approach.
What is different in Delete hierarchy compared to Delete and how can I reproduce this in Python?
Here is my Python approach for Delete hierarchy, which actually deletes "too much":
bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[fbxArmatureName].select_set(True) for child in bpy.data.objects[fbxArmatureName].children: child.select_set(True) bpy.ops.object.delete()
Can anyone help me out?