# Creating/adding socket to a static mesh with Python

**URL:** <https://forums.unrealengine.com/t/creating-adding-socket-to-a-static-mesh-with-python/153520>\
**Category:** Editor Scripting\
**Tags:** unreal-engine\
**Created:** [November 12, 2020, 10:10am UTC](https://forums.unrealengine.com/t/creating-adding-socket-to-a-static-mesh-with-python/153520 "2020-11-12T10:10:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kosuna](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kosuna](https://forums.unrealengine.com/u/Kosuna)\
**Post date:** [November 12, 2020, 10:10am UTC](https://forums.unrealengine.com/t/creating-adding-socket-to-a-static-mesh-with-python/153520/1 "2020-11-12T10:10:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Kosuna](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kosuna](https://forums.unrealengine.com/u/Kosuna)\
**Post date:** [November 12, 2020, 2:49pm UTC](https://forums.unrealengine.com/t/creating-adding-socket-to-a-static-mesh-with-python/153520/2 "2020-11-12T14:49:03Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![sanford87](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sanford87/32/906597_2.png) [@sanford87](https://forums.unrealengine.com/u/sanford87)\
**Post date:** [May 4, 2023, 6:10pm UTC](https://forums.unrealengine.com/t/creating-adding-socket-to-a-static-mesh-with-python/153520/3 "2023-05-04T18:10:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DeoVerse](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DeoVerse](https://forums.unrealengine.com/u/DeoVerse)\
**Post date:** [March 15, 2024, 5:38am UTC](https://forums.unrealengine.com/t/creating-adding-socket-to-a-static-mesh-with-python/153520/4 "2024-03-15T05:38:01Z")

</div>

worked for me thank you.
