This post was originally asking to solve a different issue with this node setup (gaps in between stacked GN objects), but as that issue has been solved by myself, the question has been edited, with permission by a Moderator (see comments below) to focus on stacking objects within a collection.
TL:DR - How can I find the scale of a random object in a geometry nodes collection node to stack those objects?
I'm attempting to create a lightweight skyscraper generator to use for a scene. Which I intend to use different collections of various meshes to make up the bottom, middle, and top sections to make modular buildings. With each piece sitting neatly on top of each other without any gaps.
The idea being, for each building, it'll pick a single base from the collection, a single middle (arrayed to a random height), and put a top on it.
It's important to note that the middle section isn't made up of random elements from the collection stacked upon each other, rather that one object is randomly chosen from the "middle" collection and arrayed to make the main body of the building. See the image below for what I mean
Essentially, I'm making the array modifier using the start and end caps option, but the objects used in the array are random.
I've arrived at some kind of solution, though it's not exactly what I need just yet. I can get objects in an array, with a start and end cap, and even offset the middle and top sections depending on the size of the base. However, it's currently only working with single objects, and not collections.
["Middle" section of the image below] I take a mesh line, and use the Z-height of the middle object's bounding box to offset the points using an "Accumulate Field" node. Then I instance the middle object. By subtracting "1" from the bounding box's Z output, this stacks the sections without gaps, no matter how tall the object is.
["Base" section of the image below] Using another mesh line, I instance the base of the building.
[Top section of the image below] I use a "points" node to instance the top cap. By finding the z-height of a single section of the middle (using a similar method as before, without the subtract), then multiplying by the amount of segments the middle's "mesh line" has (currently they're driven by random values), I can offset the top cap to place it above the middle section, no matter how high it is.
["Base offset" section of the image below] Finally, I offset the middle and top sections by the height of the base.
All in all, it works great when I plug single objects into the setup for the base/middle/top sections. However, as I'd like the buildings to be random, I need to use collections, which is where my issue lies.
Unlike the "Object Info" node, Collections lack a "scale" output, which means I can't plug it into my Bounding Box group to find out how tall a given element is. If I can't find that out, I can't offset any of the pieces, and it won't make a building.
To put it into simple terms, I need to find out how tall a given element in a collection is so I can offset them.
In a perfect world, I'd want this to work without using the "realize instances" node, since as far as I understand, it turns the mesh into "real" geometry, and can (and probably will) tank performance using this generator on the scale of an entire city. At least more so than keeping everything in "instance land".
Here's a Blend file with the current node setup.
Please know that my knowledge of geo nodes is pretty limited, and I'm stretching my ability to do even this.
Thanks in advance!