# C++ get Mesh size

**URL:** <https://forums.unrealengine.com/t/c-get-mesh-size/391638>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [April 22, 2017, 6:22pm UTC](https://forums.unrealengine.com/t/c-get-mesh-size/391638 "2017-04-22T18:22:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tensio](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tensio](https://forums.unrealengine.com/u/Tensio)\
**Post date:** [April 22, 2017, 6:22pm UTC](https://forums.unrealengine.com/t/c-get-mesh-size/391638/1 "2017-04-22T18:22:41Z")

</div>

Hello, I just started working with UE and i created a  
_My\_Mesh = CreateDefaultSubobject(TEXT(“MyMesh”));_  
Is there a way i can get the size of mesh ? i need to get x,y,z to subdivide the map into squares, triangles and hexagones to create my own custom navigation mesh.

* * *

I found out about these  
“_GetComponentBounds_” for components  
“_GetActorBounds_” for Actors.  
And i dont understand how to use them.

---

<div class="post-metadata">

**Author:** ![Benergy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Benergy](https://forums.unrealengine.com/u/Benergy)\
**Post date:** [April 24, 2017, 5:13pm UTC](https://forums.unrealengine.com/t/c-get-mesh-size/391638/2 "2017-04-24T17:13:01Z")

</div>

What about `My_Mesh->CalcBounds()`? Basically the same as GetComponentBounds but in C++.

---

<div class="post-metadata">

**Author:** ![Tensio](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tensio](https://forums.unrealengine.com/u/Tensio)\
**Post date:** [April 30, 2017, 3:34pm UTC](https://forums.unrealengine.com/t/c-get-mesh-size/391638/3 "2017-04-30T15:34:18Z")

</div>

it returns an FTransform, where can i get the size?  
Or it returns an FBoxSphereBounds… that i checked and its x,y,z are null

---

<div class="post-metadata">

**Author:** ![Benergy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Benergy](https://forums.unrealengine.com/u/Benergy)\
**Post date:** [April 30, 2017, 4:35pm UTC](https://forums.unrealengine.com/t/c-get-mesh-size/391638/4 "2017-04-30T16:35:43Z")

</div>

Have you tried calling `My_Mesh->UpdateBounds()` before? Also, are `My_Mesh->CalcBounds().BoxExtent` and `My_Mesh->CalcBounds().SphereRadius` both zero?

---

<div class="post-metadata">

**Author:** ![Tensio](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tensio](https://forums.unrealengine.com/u/Tensio)\
**Post date:** [April 30, 2017, 5:28pm UTC](https://forums.unrealengine.com/t/c-get-mesh-size/391638/5 "2017-04-30T17:28:59Z")

</div>

FTransform transform ;  
FVector vector = My\_Mesh-\>CalcBounds(transform ).GetBox().GetSize();  
this returns negative values. I am not sure if this is the correct way of getting the size. Also what is the transform needed for, is it the a transform that will get a value when i call calcBounds, or is the function CalcBonds calculating the bounds of the transform ?

* * *

SphereRadius returned 536870912  
and BoxExtent returned negative values

---

<div class="post-metadata">

**Author:** ![Benergy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Benergy](https://forums.unrealengine.com/u/Benergy)\
**Post date:** [May 1, 2017, 12:22pm UTC](https://forums.unrealengine.com/t/c-get-mesh-size/391638/6 "2017-05-01T12:22:54Z")

</div>

When you call `UStaticMeshComponent::CalcBounds(FTransform& LocalToWorld)`, first the bounds of the mesh are fetched, and then they are transformed by the LocalToWorld transform. So when you have a transform with a location and a rotation, the bounds are translated and rotated.

Also notice that the mesh of the UStaticMeshComponent must be set first.

---

<div class="post-metadata">

**Author:** ![Tensio](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tensio](https://forums.unrealengine.com/u/Tensio)\
**Post date:** [May 28, 2017, 9:48am UTC](https://forums.unrealengine.com/t/c-get-mesh-size/391638/7 "2017-05-28T09:48:31Z")

</div>

Thank you all for your help.  
My\_Mesh-\>CalcBounds().BoxExtent  
Was the solution to get the distance.
