Godot Version
Godot v4.3.rc3.mono - Linux Mint 22 (Wilma) - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4060 Ti (nvidia; 535.183.01) - AMD Ryzen 7 5700X 8-Core Processor (16 Threads)
Question
How do I set the Bone Map from a bone_map.tres via GDScript?
I want to do the equivilent of setting the retargetting of the bone map by loading the bone_map.tres file in the Advanced Import pane.
I have been all over the docs and just can’t find the answer.
1 Like
I would add a Question to this, if anyone find the anser is there any possibility to set the BoneMap via : EditorScenePostImport ? (the Import Script)
and in the same vibe how can we create Preset for imports ?
So I guess I never came back to this.
So the short answer is “you can’t”, both to my question and to @g-raffiti 's question as well. I spoke to Lyuma about it and he is working on improving the API. I was hoping to see that in 4.4, but he didn’t get it in on time. Maybe 4.5 will see the API enhancement.
The reason it won’t work in post import is the bones need to be assigned pre-import, so it know how to assign the rigging to the bones not-post import. The bone assignments need to be there already when importing the assets using the post import script, if you do it after, the asset rig isn’t mapped to the bones.
As I mentioned, it is being worked on, but I do not have a timeline and I don’t want to make promises on someone’s elses behalf. You can read about it in this issue if you wish and also learn some partial workarounds that “sorta” get you there, but won’t let you fully automate importation of more than one animation library at a time.
opened 02:47AM - 13 Aug 24 UTC
closed 11:27PM - 07 Jan 25 UTC
bug
topic:import
### Tested versions
- Reproducible in all 4.x versions.
### System informa… tion
Godot v4.3.rc3.mono - Linux Mint 22 (Wilma) - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4060 Ti (nvidia; 535.183.01) - AMD Ryzen 7 5700X 8-Core Processor (16 Threads)
### Issue description
The ConfigFile class set_value method erases key/value pair when value is set to null (this is per class docs for ConfigFile.set_value). However, some files such as .glb.import files have required keys stored with explicit values for some options.
There is already the method erase_section() and erase_section_key(), and we need the ability to write null values to key/value pairs.
Example for when we need to be able to write an explicit null:
```
[params]
{_subresources={
"nodes": {
"PATH:Armature/Skeleton3D": {
"rest_pose/external_animation_library": null,
"retarget/bone_map": Resource("res://explosive_bone_map.tres")
}
}
}
```
If this value is not set, then the entire PATH:Armature/Skeleton3D node is over written by the engine on the next import.
Thus an entry to set skeleton ex. {"nodes" : {"PATH:Armature/Skeleton3D": {"retarget/bone_map": Resource("res://bone_map.tres")}}} will also be erased and unset.
To justification that a change is needed:
If one copies and pastes a correct but partial entry, the editor will erase the incomplete entry upon next import...example:
```
_subresources={
"nodes": {
"PATH:Armature/Skeleton3D": {
"retarget/bone_map": Resource("res://explosive_bone_map.tres")
}
}
}
```
becomes:
`_subresources={}`
If one copies and pastes the complete correct node entry with the required null value, the editor is fine. example:
```
_subresources={
"nodes": {
"PATH:Armature/Skeleton3D": {
"rest_pose/external_animation_library": null,
"retarget/bone_map": Resource("res://explosive_bone_map.tres")
}
}
}
```
Therefore one must conclude that the Class used to read and write configuration files such as .import files, should be able to write key/value pairs that include explicit null values.
There is already the method erase_section() and erase_section_key(), and we need the ability to write null values to key/value pairs.
### Steps to reproduce
```
@tool # Needed so it runs in editor.
extends EditorScenePostImport
var config = ConfigFile.new()
func _post_import(scene):
set_skeleton()
func set_skeleton() -> void:
var bone_map : BoneMap = load("res://explosive_bone_map.tres")
config.load("res://relax.glb.import")
var rest_pose_node : Dictionary
rest_pose_node = {"nodes" : {"PATH:Armature/Skeleton3D": {"rest_post/external_animation_library": null}}}
config.set_value("params", "_subresources", rest_pose_node)
config.save("res://relax.glb.import")
```
### Minimal reproduction project (MRP)
[Animation Test.zip](https://github.com/user-attachments/files/16593811/Animation.Test.zip)
EDIT: I said FBX by mistake up above, I corrected that to GLB....I am not sure if that's important or not...I would expect the import file behavior to be the same for either.