# Save SkeletalMesh from  USkeletalMergingLibrary::MergeMeshes to .uasset

**URL:** <https://forums.unrealengine.com/t/save-skeletalmesh-from-uskeletalmerginglibrary-mergemeshes-to-uasset/1734497>\
**Category:** Programming & Scripting\
**Tags:** merge, save-file, unreal-engine, question\
**Created:** [March 6, 2024, 7:43pm UTC](https://forums.unrealengine.com/t/save-skeletalmesh-from-uskeletalmerginglibrary-mergemeshes-to-uasset/1734497 "2024-03-06T19:43:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yaulp](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yaulp/32/906820_2.png) [@Yaulp](https://forums.unrealengine.com/u/Yaulp)\
**Post date:** [March 6, 2024, 7:43pm UTC](https://forums.unrealengine.com/t/save-skeletalmesh-from-uskeletalmerginglibrary-mergemeshes-to-uasset/1734497/1 "2024-03-06T19:43:44Z")

</div>

Hi everyone !  
I want to save a SkeletalMesh made with MergeMeshes to .uasset.  
I made this function that can save UObjects to .uasset :

```auto
UFUNCTION(BlueprintCallable)
static bool SaveToAsset(UObject* object, FString path, FString name)
{
	UE_LOG(LogTemp, Warning, TEXT(" ~~~~~~~~~~Saving to asset...~~~~~~~~~~"));
	if (object == NULL) {
		UE_LOG(LogTemp, Error, TEXT("Object is null."));
		return false;
	}
	// Find unique name and create package
	FString Name = name;
	for (int i = 1; FPackageName::DoesPackageExist(FString("/Game/" + path + Name)); i++)
		Name = name + FString::FromInt(i);
	UPackage* Package = CreatePackage(*FString("/Game/" + path + Name));
	UE_LOG(LogTemp, Warning, TEXT("Package created : %s"), *(Package->GetName()));

	// Duplicate object
	FObjectDuplicationParameters p(object, Package);
	p.DestName = FName(Name);
	UObject* DuplicatedObject = StaticDuplicateObjectEx(p);
	DuplicatedObject->SetFlags(RF_Public | RF_Standalone);

	// Save and return
	FString PackageFileName = FPackageName::LongPackageNameToFilename(Package->GetName(), FPackageName::GetAssetPackageExtension());
	bool bSucceeded = UPackage::SavePackage(Package, DuplicatedObject, DuplicatedObject->GetFlags(), *PackageFileName);
	if (bSucceeded) UE_LOG(LogTemp, Warning, TEXT("Saving Package succeded.")) else UE_LOG(LogTemp, Error, TEXT("ERROR : FAILED SAVING PACKAGE !"));
	return bSucceeded;
}

```

It works for the SkeletalMeshes I tried, and for most others UObjects.

But when I try to save the SkeletalMesh made with USkeletalMergingLibrary::MergeMeshes, if I click on the Content Drawer, Unreal crash.

 ![Nodes](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/4/7/9476cca8e172c574c8ba8bd3e4564e9e696242e1.png)

Here is the end of the LOG :

```auto
[2024.03.06-18.54.51:269][482]LogTemp: Warning: ~~~~~~~~~~Saving to asset...~~~~~~~~~~
[2024.03.06-18.54.51:269][482]LogTemp: Warning: Package created : /Game/Assets/Humans/Metahuman/Preview/MergeMeshes_Saved
[2024.03.06-18.54.51:342][482]LogPackageLocalizationCache: Processed 64 localized package path(s) for 1 prioritized culture(s) in 0.012199 seconds
[2024.03.06-18.54.51:352][482]LogSavePackage: Moving output files for package: /Game/Assets/Humans/Metahuman/Preview/MergeMeshes_Saved
[2024.03.06-18.54.51:352][482]LogSavePackage: Moving '../../../../../../Users/Yaulp/Desktop/Unreal Projects/Game 5.3/Saved/MergeMeshes_Saved4454B5C74641DC680DA139880527D0F6.tmp' to '../../../../../../Users/Yaulp/Desktop/Unreal Projects/Game 5.3/Content/Assets/Humans/Metahuman/Preview/MergeMeshes_Saved.uasset'
[2024.03.06-18.54.51:353][482]LogTemp: Warning: Saving Package succeded.
[2024.03.06-18.54.51:355][482]LogViewport: Scene viewport resized to 1920x1006, mode Windowed.
[2024.03.06-18.54.51:369][482]PIE: Server logged in
[2024.03.06-18.54.51:370][482]PIE: Play in editor total start time 0,898 seconds.
[2024.03.06-18.54.51:410][482]LogViewport: Scene viewport resized to 1914x966, mode Windowed.
[2024.03.06-18.54.51:756][483]AssetCheck: New page: Asset Save: MergeMeshes_Saved
[2024.03.06-18.54.51:756][483]LogContentValidation: Display: Validating /Script/Engine.SkeletalMesh /Game/Assets/Humans/Metahuman/Preview/MergeMeshes_Saved.MergeMeshes_Saved
[2024.03.06-18.54.57:648][828]LogWorldSubsystemInput: UEnhancedInputDeveloperSettings::bEnableWorldSubsystem is false, the world subsystem will not be created!
[2024.03.06-18.54.57:656][828]LogOutputDevice: Warning: 

Script Stack (0 frames) :

[2024.03.06-18.54.57:671][828]LogWindows: Error: appError called: Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Containers\Array.h] [Line: 771] 
Array index out of bounds: 0 from an array of size 0

[2024.03.06-18.54.57:671][828]LogWindows: Windows GetLastError: L’opération a réussi. (0)
[2024.03.06-18.54.59:303][828]LogWindows: Error: === Critical error: ===
[2024.03.06-18.54.59:303][828]LogWindows: Error: 
[2024.03.06-18.54.59:303][828]LogWindows: Error: Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Containers\Array.h] [Line: 771] 
[2024.03.06-18.54.59:303][828]LogWindows: Error: Array index out of bounds: 0 from an array of size 0
[2024.03.06-18.54.59:303][828]LogWindows: Error: 
[2024.03.06-18.54.59:303][828]LogWindows: Error: 
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ffcd5cfdbc7 UnrealEditor-Engine.dll!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ffcd49fa7b7 UnrealEditor-Engine.dll!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ffcd49df739 UnrealEditor-Engine.dll!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ffcd4a42a8c UnrealEditor-Engine.dll!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ffcd2dd0c43 UnrealEditor-UnrealEd.dll!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ffcd2d971c6 UnrealEditor-UnrealEd.dll!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ffcd295f19c UnrealEditor-UnrealEd.dll!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ffcd1be6c97 UnrealEditor-UnrealEd.dll!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ffcd1c40fe1 UnrealEditor-UnrealEd.dll!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ffcd1c70e45 UnrealEditor-UnrealEd.dll!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ffcd22678ac UnrealEditor-UnrealEd.dll!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ffcd22647e7 UnrealEditor-UnrealEd.dll!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ffcd2ebea06 UnrealEditor-UnrealEd.dll!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ff70b068af2 UnrealEditor.exe!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ff70b08d28c UnrealEditor.exe!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ff70b08d37a UnrealEditor.exe!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ff70b090854 UnrealEditor.exe!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ff70b0a6984 UnrealEditor.exe!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ff70b0a9d7a UnrealEditor.exe!UnknownFunction []
[2024.03.06-18.54.59:303][828]LogWindows: Error: [Callstack] 0x00007ffd26377344 KERNEL32.DLL!UnknownFunction []

```

In addition, the asset has a size of 142 KB while just the body has a size of 17 MB :  
 ![Taille](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/a/a/daa65e1829b95922543e70e9225d8864c9b07587.png)

I thought it was due to the missing LODs, so I tried this but it crashed too :

```auto
FLODUtilities::RegenerateLOD(Cast<USkeletalMesh>(DuplicatedObject), ITargetPlatform::GetPlatformFromOrdinal(25), 4, true, true);

```

Thanks in advance to anyone who will try to help me, if any. I tried to do everything I could.

---

<div class="post-metadata">

**Author:** ![tomaaron872](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tomaaron872](https://forums.unrealengine.com/u/tomaaron872)\
**Post date:** [July 24, 2024, 4:00pm UTC](https://forums.unrealengine.com/t/save-skeletalmesh-from-uskeletalmerginglibrary-mergemeshes-to-uasset/1734497/2 "2024-07-24T16:00:56Z")

</div>

Did you ever found a solution?

---

<div class="post-metadata">

**Author:** ![TheArrow20](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheArrow20](https://forums.unrealengine.com/u/TheArrow20)\
**Post date:** [September 14, 2024, 11:15am UTC](https://forums.unrealengine.com/t/save-skeletalmesh-from-uskeletalmerginglibrary-mergemeshes-to-uasset/1734497/3 "2024-09-14T11:15:32Z")

</div>

Hello, did you find solution ?

I tried everything from custom C++ code to builtin asset tools duplicate fonctionnality.  
Seems the generated mesh is not working with conventional duplicate.

I can also confirm this is an issue with the SkeletalMeshMerger tool, duplicating another skeletal mesh asset is working fine.
