I need to automate the creation of sockets on all bones in a skeletal mesh. I use the provided script but it does not work as expected. In the first image you can see the result of the python script. And in the second it is the result by manually adding sockets in the editor.
If you are able to provide a Python snippet that does this in Unreal 5.8.2 I would be really grateful!
I believe the socket needs to be created via new_object and outered to the mesh before calling AddSocket. Something like this should work in your for loop:
You’ll need to do this after the call to add_socket, as that’s where we’ll automatically generate a temporary name. You can then pass the resulting socket’s socket_name as the old_name for the rename operation.
It adds the socket to the correct bone and renames the socket as expected, but the socket is added to the Mesh not the skeleton as specified in the “add_socket” function? Am I missing something?
The call to add_socket here should add it to both the mesh and the skeleton, though you may need to save the skeleton as well:
unreal.EditorAssetLibrary.save_loaded_asset(skeletal_mesh_asset.get_editor_property("skeleton"))If you don’t want to add it to the mesh and only want the socket added to the skeleton, you could remove it afterward with something like:
Ah, sorry about all the back and forth. It doesn’t seem like the Python API supports creating the socket on the skeleton without also creating it on the mesh, so that might require an engine change if it’s something you need to support. Otherwise, it should currently be adding to both, even if it only looks like it’s on the mesh.