How to Stack Static Meshes with Different Heights on Top of Each Other using for each loop?

Hi I want to create a tool within Editor Utility Widget that stacks selected meshes on top of each other how would I do this?

You can do this in the Editor Utility Widget with a running “current Z” value. Get the selection with Get Selected Level Actors (Editor Actor Subsystem), then optionally sort it (e.g. by current Z) so the order is predictable. Before the loop, set a float CurrentZ to the bottom of the first actor. In the For Each Loop, call Get Actor Bounds (Only Colliding Components unchecked) on each actor: it returns Origin and Box Extent. The offset between the pivot and the bottom of the mesh is (ActorLocation.Z - (Origin.Z - BoxExtent.Z)), so set the new location Z to CurrentZ + that offset, keep X/Y from the first actor, and call Set Actor Location. Then increase CurrentZ by BoxExtent.Z * 2 (the full height) before the next iteration. Using the bounds instead of the pivot is what makes meshes with different heights and off-center pivots stack cleanly, and wrapping it in a transaction (Begin Transaction / End Transaction) makes it undoable with Ctrl+Z.

Is there anyway you can show me a example blueprint?

Thank you

To take it further (and simplify it greatly at the same time) and, especially if your meshes are more complex, like a T shape rotated 45 degrees landing on a triangle, consider Sweeping:

You could do the whole thing with a ForEachLoop and this one node for any number of Static Mesh Actors. Note that here you’d depend on the fidelity of the collider rather than the mesh’s dimensions per se.