Creating/adding socket to a static mesh with Python

I made a script that creates StaticMeshSocket objects and adds them to a Static Mesh with some coordinates. The problem is when I reload my project I cant open my Static Mesh anymore, everything just crashes.

I assume that my Static Mesh cannot find a reference to socket objects after I restart. If so how am I supposed to save these socket objects?

Problem solved! Turns out when im creating StaticMeshSocket objects its not enough to type mySocket = unreal.StaticMeshSocket() , you have to specify your static mesh mySocket = unreal.StaticMeshSocket(outer = meshReference). Didn’t know what outer means or if it was necessary since im already referencing my mesh when I type meshReference.add_socket(mySocket).

2 Likes

smc =static_mesh_assets[0]
index = 0
for x in z:
mySocket = unreal.StaticMeshSocket(outer = smc)
mySocket.set_editor_property(‘relative_location’, y)
socketName = ‘keypoint_’ + str(index)
mySocket.set_editor_property(‘socket_name’, socketName)
unreal.StaticMesh.add_socket(smc, mySocket)
index = index + 1

1 Like

worked for me thank you.

1 Like