Copy static mehs sockets

Hi, is there a way to copy sockets from one Static mesh to another?

This would be helpful to speed up socket placement.

Looking for the same thing. Would like this feature implemented if it doesn’t exist,

This really annoyed me, so I came up with a blueprint library helper function, and a blutility to accomplish this.

The code for the function is:

void UTOTGameBPLibrary::ReplaceStaticMeshSockets(class UStaticMesh *Source, class UStaticMesh *Dest)
{
#if WITH_EDITOR
	if (Source != nullptr && Dest != nullptr && Source != Dest)
	{
		if (Source->Sockets.Num() > 0)
		{
			Dest->PreEditChange(NULL);
			Dest->Sockets.Empty();
			for (int32 i = 0; i < Source->Sockets.Num(); i++)
			{
				auto Sock = Source->Sockets[i];

				UStaticMeshSocket *NewSocket = NewObject<UStaticMeshSocket>(Dest);
				NewSocket->SocketName = Sock->SocketName;
				NewSocket->SetFlags(RF_Transactional);
				NewSocket->RelativeLocation = Sock->RelativeLocation;
				NewSocket->RelativeRotation = Sock->RelativeRotation;
				NewSocket->RelativeScale = Sock->RelativeScale;
				NewSocket->Tag = Sock->Tag;
				Dest->Sockets.Add(NewSocket);
			}
			Dest->PostEditChange();
			Dest->MarkPackageDirty();
		}
	}
#endif
}

and here is a screenshot of the Blutility:

5 Likes

Feature still isn’t there. Incredibly inconvenient that you cannot just copy all the sockets from a mesh to another mesh. :expressionless:

2 Likes

Hey, in Unreal Engine 5 you cannot import sockets into Unreal Engine as they are generated automatically by the editor based on the mesh’s pivot point and geometry. You can copy sockets from one mesh to another using the following steps:

  • To copy sockets between meshes, you can select the source mesh and then select all the sockets you want to copy by holding down the Ctrl key and clicking on each socket.
  • Then, right-click on one of the selected sockets and choose “Copy”.
  • Next, select the destination mesh and right-click in the viewport to bring up the context menu.
  • Choose “Paste Sockets Here” and the sockets will be added to the destination mesh.

Please note that this method only works if the meshes have the same number of vertices and are similar in shape. Hope this helps anyone thinking it is still not possible :slight_smile:

1 Like

Are you talking about Skeletal Meshes? I’m asking because in static meshes you can’t even select multiple sockets and there’s no “copy” option.

Thanks for your code, I extended it and made a plugin for UE5.1+, I’ll leave it here in case anyone needs it:

StaticMeshUtilities.zip (11.4 MB)

It allows you to:

  • Copy sockets from a source static mesh to N meshes, and choose whether or not to preserve the existing ones
    image

  • Delete all the sockets from N static meshes

  • Create multiple sockets at once with a sequential number and a progressive offset
    image

Example of the result of the previous window:

4 Likes

Wow nice. Should put that in the store. :+1:

Quick question. How do you get that to work?

  • added it to “Project/Plugins/StaticMeshUtilities”
  • added entry to the Plugins section of the .UProject file
  • generated project files
  • compiled with no errors
  • plugin shows as enabled in the Project >> Plugins

But do not see any options for it on the static mesh editor screen …

Righ click one (or multiple) static mesh(es) and you should be able to see a new entry in the context menu called “scripted asset actions”

1 Like

Ahh nice it works. :+1:

1 Like

I installed it exactly like @Shmoopy1701 said but i do not see it pop up in the context menu? I’m in 5.0

1 Like

It’s made for 5.1 so it’s normal it’s not working in previous engine versions, it should work if you recompile the C++ code but you need to recreate the asset action utility ('cause blueprints are not backward compatible).

I’ll share a 4.27 compatible version as soon as I have some free time

2 Likes

Ahh nice. Yep we have projects in multiple engine versions as well.

Weird that even copy pasting the blueprint nodes to a previous engine version doesn’t work either. You have to totally recreate the blueprint from scratch. :expressionless:

Yeah, I’ve been there too… I hate I can’t even copy material nodes to previous engine versions (so whenever I create a plugin for the marketplace I always try to make it in an older Engine version, this was not the case because I needed it in a project in particular).

2 Likes

Thank you for this.

3 Likes

Your plugin is a game changer. Thank you so much for sharing it! This will save me so much time.

2 Likes