7
$\begingroup$

Is there a way how to get the individual bounding box size of each object inside a collection?

It's easy to get the bounding box size for an individual object, but I don't know how to do this for multiple objects inside a collection.

I don't want to get the whole collection bounding box, I need the local Y-length of each object.

Is there maybe already a field, where the data is stored?

$\endgroup$
3
  • $\begingroup$ Unfortunately, this is only possible in a roundabout way. And Bounding Box is an object that consists of several values. Which values do you need exactly? $\endgroup$
    – quellenform
    Sep 7, 2022 at 10:20
  • $\begingroup$ I just need the local y-length of every object. $\endgroup$ Sep 7, 2022 at 10:23
  • $\begingroup$ Have a look at the Capture Instance Dimensions group in this answer $\endgroup$
    – Robin Betts
    Sep 7, 2022 at 12:45

3 Answers 3

6
$\begingroup$

Find the length of one side of the Bounding Box

You can solve this as follows:

enter image description here

Here I first create a Bounding Box for each instance. Don't forget to activate the option Separate Children in the node Collection Info.

Then I use Realize Instances to convert these Bounding Boxes into a mesh.

A Bounding Box is a cuboid with 12 edges. One of the edges running on the local Y-axis always has the index $1$.

So I can conveniently filter this out here with Separate Geometry.

enter image description here
Note: Index $1$ always corresponds to the Y-axis, $2$ to the X-axis and $3$ to the Z-axis.

By converting this edge into a curve, the node Spline Length then directly returns the length of this former edge, and you have the value you are looking for.

Of course you can also calculate the length with the node Edge Vertices if you want to process the positions directly:

enter image description here

Dimensions of the Bounding Box

Alternatively, you can also capture the lengths of all three local axes at the same time:

enter image description here enter image description here

Here I first separate one of the edges on all three axes of each object (Thanks to @GordonBrinkman for the trick with comparing float values and epsilon!).

Then I capture the lengths of these edges and transfer them to the instances with Combine XYZ.

This way you have all three lengths available for each object separately.

Bounding Box as Node Group

However, it would actually be much more convenient to implement the whole thing as a reusable node group that could be used in almost exactly the same way as the node Bounding Box.

Let's call this group "Instances Bounding Box".

enter image description here

This can be solved as follows:

enter image description here enter image description here

The trick here is that I simply filter the first and the last point of the bounding box geometry and their positions.

However, since these are absolute positions, they must be set in relation to the current object.

The positions generated in this way are then exactly the values that the node Bounding Box would also supply.


(Blender 3.1+)

$\endgroup$
3
  • $\begingroup$ Thank you for your solution. I'll take it and check if it fits my needs here. It's a part of a bigger tree. I'll drop a line, if I've still questions. @GordonBrinkmann You're basically right. Knowing all three values (x,y,z) is always good. $\endgroup$ Sep 7, 2022 at 12:33
  • 1
    $\begingroup$ I can't believe I've just written the core of this answer all over again, with pretty much the same method. I must be going senile. $\endgroup$
    – Robin Betts
    Sep 7, 2022 at 13:04
  • $\begingroup$ @quellenform Yep, good idea :D $\endgroup$ Sep 7, 2022 at 14:26
4
$\begingroup$

It's essential exactly the same way as quellenform does it, but maybe a bit more obvious way:

enter image description here

enter image description here

$\endgroup$
3
  • 2
    $\begingroup$ Well done! But this time there is no upvote from me for once, because the question was actually: "individual object sizes" (plural!), so not only one object. ;-) ...or did I misunderstand something? $\endgroup$
    – quellenform
    Sep 7, 2022 at 11:11
  • $\begingroup$ yep, i think you are right! $\endgroup$
    – Chris
    Sep 7, 2022 at 11:28
  • $\begingroup$ Thank you for your idea, Chris. Also nice. But yes, I need it for multiple objects. But we could also use the index node for the selection in your tree, right? $\endgroup$ Sep 7, 2022 at 12:29
4
$\begingroup$

This is a version as posted in a different context some time ago, tidied up a little.

It's a Capture Instance Dimensions group, which works by deleting all but the max and min vertices of realized Bounding Box instances on two branches, and using the fact that the vertex-indices of the resulting geometries correspond to the instance-indices in the original collection, to make the transfers:

enter image description here

Here shown used to pack a collection of randomly-scaled monkeys without realizing them:

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ ...Please do not forget to save this node group as an asset this time :D $\endgroup$
    – quellenform
    Sep 7, 2022 at 15:49
  • 2
    $\begingroup$ @quellenform :P ... but I don't truly understand it ... posting a Q of my own.. $\endgroup$
    – Robin Betts
    Sep 7, 2022 at 16:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .