Download

"Get Dimensions" function/Blueprint node for StaticMesh assets

Hey everyone!

I don’t know if I’m alone in this, but I’ve worked on a couple of Blueprint systems that need to know the size of meshes in order to work properly. Right now, there seems to be no way to get the dimensions of a static mesh asset without it first existing in the world as a StaticMeshComponent or -Actor.

The workaround I’ve used so far is to add a new static mesh component, calculate the linear sizes from its bounds, and then destroy the component again - but that seems pretty wasteful.

So, here’s my request: Could we perhaps get a function that returns the dimensions of a static mesh asset directly?

Best,
Jan

+10000000.

Agree, we generally need a way to access anything in a blueprint without creating it, so not only the bounds but also variables etc :slight_smile:

That sounds a bit strange.
How do you want to access something that does not exist?
If its a mesh variable, how would you know what mesh its referencing later on?
If its a mesh component, it already exists…

All variables are declared at design time. I dont get what you mean in terms of “creating variables”

Can you give an example use case of what you want to achieve with this and how you would use it.
So far, I havent encountered a scenario that “Get Local Bounds” wouldnt solve…

Hmm I can think of a scenario.
Let’s say that you want to spawn an object with the right offset so it fits exactly next to another… it would be useful to be able to get the dimensions before spawn.

It’s more for convenience really, it can be done either way.

Local Bounds only works on existing components. Edit to clarify: I would love for it (or something like it) to work with assets, too - i.e., content browser static mesh assets that do not yet exist in game. In my case, I’ve encountered the need for this in two different systems I’ve built already, both meant as a tool for sale on the marketplace - meaning that users would use their own meshes and assets with them, and I don’t know how big they’ll be.

The first case is a system to create networks of spline meshes, with an arbitrary number of sub-meshes. I need to check the size of the main mesh along the forward axis used by the spline, to make sure my auto-tile feature that figures out how many meshes to add over the length of the spline automatically works.

Edited, because it’s 6 am and I haven’t slept yet, so I gave inaccurate info :wink: The first case is the only one where it’s actually necessary, in the second case it was just a matter of convenience.

So just spawn the object, get the size and move it then.
I made a “linear stairs” brush that spawns a cube, scales it to the appropriate step dimensions and moves it into place.
All meshes are created, then scaled and moved…
I also made a Fasade system that follows the same route. (See screenshots at the end of the post)
https://forums.unrealengine.com/showthread.php?67946-How-to-change-mobility-setting-for-new-static-mesh-components&highlight=kvogler

Here I scale an object to absolute dimension, regardless of its initial native size:
(The pivot needs to in the center for this to work, but my assets account for that)
SmartBrush2.JPG

In this case, create the first mesh, examine it and then run the loop from there (minus one tile).

As I mentioned, spawning is not feasible because these things happen at editor time in the construction script.

I also described in the OP that my workaround basically does exactly that, except using “add component” - but it’s an unnecessary and not exactly cheap step to do every time the actor updates, which, when you drag around spline points, is supposed to happen per frame. Especially since the component serves no other function, because the actual system uses spline mesh components, not static mesh components. When you do that to dozens of meshes every frame, it creates some overhead that really shouldn’t be necessary. :wink:

Besides, this is not a “help me with blueprints” thread, but a feature request :stuck_out_tongue:

The same as my stuff…

All I wanted is to point out that there is a valid workflow that makes this feature request superflous in my oppinion. :stuck_out_tongue:

I know there’s a workaround, and I’m already using it, as I described in the OP. But I’m basically creating, measuring, and then destroying a component for the sole purpose of getting data that is available in the asset browser directly, and that’s terribly inefficient - and I’ve run into it often enough that it made me consider making this thread, so…

I recently had to know my static mesh dimensions during runtime, which doesn’t exist in the engine. I really recommend adding this feature.

Hi! Not sure how useful this is, but I am only using a staticmesh actor reference in the blueprint, not an actor, and not a component and using the UStaticMesh->CalculateExtendedBounds() and then UStaticMesh->GetBoundingBox(), then I am spawning the mesh component along a spline, so I also can not spawn measure and readjust as my size determines my loop count.

This works for me, no need to spawn and measure but you do need a reference to the static mesh itself somewhere in the blueprint via UStaticMesh.

Side note: SplineMeshClass->GetBounds().BoxExtent for this particular mesh was exactly half the scale of the bounding box, and bounding box also matches the Approx Size values I see on screen when opening the mesh.

Good luck!