# How to modify my function which converts Skeletal mesh to procedural mesh, to only convert specified bones to procedural mesh, not the full mesh 

**URL:** <https://forums.unrealengine.com/t/how-to-modify-my-function-which-converts-skeletal-mesh-to-procedural-mesh-to-only-convert-specified-bones-to-procedural-mesh-not-the-full-mesh/2523004>\
**Category:** Programming & Scripting\
**Tags:** procedural-mesh-comp, unreal-engine, skeletalmesh, question, CPP\
**Created:** [May 22, 2025, 1:52pm UTC](https://forums.unrealengine.com/t/how-to-modify-my-function-which-converts-skeletal-mesh-to-procedural-mesh-to-only-convert-specified-bones-to-procedural-mesh-not-the-full-mesh/2523004 "2025-05-22T13:52:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richy-1997](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Richy-1997](https://forums.unrealengine.com/u/Richy-1997)\
**Post date:** [May 22, 2025, 1:52pm UTC](https://forums.unrealengine.com/t/how-to-modify-my-function-which-converts-skeletal-mesh-to-procedural-mesh-to-only-convert-specified-bones-to-procedural-mesh-not-the-full-mesh/2523004/1 "2025-05-22T13:52:04Z")

</div>

So I have a code snippet guys, which converts a given skeletal Mesh to Procedural mesh at runtime, but I need a different functionality, I want it to only convert some bones, not the full skeletal mesh,  
for example, if Input is given : upperarm\_l, then it will show upperarm\_l, lowerarm\_l, and hand\_l but not the other bones in procedural mesh,  
here is the code that I have

```auto
void UGore::CopySkeletalMeshToProcedural(USkeletalMeshComponent* SkeletalMeshComponent, int32 LODIndex, FName InTargetBoneNaming)
{
	if (!SkeletalMeshComponent || !ProcMeshComponent) return;

	FSkeletalMeshRenderData* SkMeshRenderData = SkeletalMeshComponent->GetSkeletalMeshRenderData();
	const FSkeletalMeshLODRenderData& DataArray = SkMeshRenderData->LODRenderData[LODIndex];
	FSkinWeightVertexBuffer& SkinWeights = *SkeletalMeshComponent->GetSkinWeightBuffer(LODIndex);

	TArray<FVector> VerticesArray;
	TArray<FVector> Normals;
	TArray<FVector2D> UV;
	TArray<int32> Tris;
	TArray<FColor> Colors;
	TArray<FProcMeshTangent> Tangents;

	int32 NumSourceVertices = DataArray.RenderSections[0].NumVertices;

	for (int32 i = 0; i < NumSourceVertices; i++)
	{
		FVector SkinnedVectorPos = USkeletalMeshComponent::GetSkinnedVertexPosition(SkeletalMeshComponent, i, DataArray, SkinWeights);
		VerticesArray.Add(SkinnedVectorPos);

		FVector ZTangentStatic = DataArray.StaticVertexBuffers.StaticMeshVertexBuffer.VertexTangentZ(i);
		FVector XTangentStatic = DataArray.StaticVertexBuffers.StaticMeshVertexBuffer.VertexTangentX(i);

		Normals.Add(ZTangentStatic);
		Tangents.Add(FProcMeshTangent(XTangentStatic, false));

		FVector2D uvs = DataArray.StaticVertexBuffers.StaticMeshVertexBuffer.GetVertexUV(i, 0);
		UV.Add(uvs);

		Colors.Add(FColor(0, 0, 0, 255));
	}

	FMultiSizeIndexContainerData indicesData;
	DataArray.MultiSizeIndexContainer.GetIndexBuffer(indicesData.Indices);

	for (int32 i = 0; i < indicesData.Indices.Num(); i++)
	{
		uint32 a = indicesData.Indices[i];
		Tris.Add(a);
	}

	// ✅ Create the procedural mesh
	ProcMeshComponent->CreateMeshSection(0, VerticesArray, Tris, Normals, UV, Colors, Tangents, true);
	ProcMeshComponent->SetWorldTransform(SkeletalMeshComponent->GetComponentTransform());

	// ✅ Hide original skeletal mesh
	AActor* Owner = GetOwner();
	if (Owner)
	{
		USkeletalMeshComponent* Mesh = Owner->FindComponentByClass<USkeletalMeshComponent>();
		if (Mesh)
		{
			Mesh->SetVisibility(false);
		}
	}
	ProcMeshComponent->SetVisibility(true);
}

```

Thankyou for reading through
