Alright. I asked because it could be an XY problem and I cannot know what you need this Y-size for nor how frequently.
GetBoundingBox()
is definitely the quickest method, but if having the mentioned world axis-aligned primary part is not an option, then you can use one of the bounding box algorithms.
I recommend taking a look at XAXA’s function, derived from the engine source.
It comes with a caveat. Engine calculations are always going to be much faster. AABB operation complexity is linear. Even if completely optimised and compiled as --!native
, this function will be around two orders of magnitude slower at best. With each additional part the execution time grows, while it hardly changes for GetBoundingBox()
, even in large models.
Edit. Just below the XAXA’s post Pyseph added a faster version.