1
$\begingroup$

This question shows how you can build a node tree to select between mesh 1, 2 or 3, but it's pretty manual. Is there some way to do this for an arbitrary number of meshes, so you can add extra meshes without having to build extra node branches?

This is how I imagine it could work

$\endgroup$
2
  • 4
    $\begingroup$ Collection Info node $\endgroup$ Commented Feb 5 at 11:17
  • $\begingroup$ Brilliant - that's exactly what I needed. Thanks! $\endgroup$
    – Nickh129
    Commented Feb 5 at 12:16

2 Answers 2

2
$\begingroup$

The credit for this answer actually belongs to @MarkusvonBroady as he mentioned it in the comments, and it seemed to be what was asked for. But for all people who cannot figure it out with the hint at Collection Info node, I thought I'll give a longer explanation.

First of all, here is a possible nodetree:

nodetree

With the Collection Info (make sure Separate Children is enabled to work correctly) you can use a Separate Geometry node set to Instance to pick the object which Index is equal to the value you choose.

In the example I connected the one integer input of the Math > Compare > Equal node to the Group Input to be able to select the object in the modifier. Then I have a collection called "objects" which contains the objects I want to choose from. Each object gets an index from 0 to $n$ - 1 for $n$ objects in the collection. The comfortable thing is, every object you put in this collection can then be chosen without the need to change the nodetree.

One important thing to note though: objects put in a collection will be sorted alphabetically, and therefore re-sorted whenever this alphabetical order changes. And then the index numbers will be re-arranged, too - they will always go from 0 for the top object to $n$ - 1 for the bottom object. An object does not keep its index if it is sorted into a different position in the list.

Which means, if you chose object 3 to display and suddenly you add a new object that gets placed above it in the list, index 3 would no longer select the object you originally chose and you would now have to switch to index 4.

By the way, it is possible that after adding a new object to the collection, the selection still shows the object you originally chose although the order has changed. This is temporarily because the nodetree might not have been refreshed. As soon as it is by maybe switching the index number etc., the new order of elements is established.

If this is not relevant, you can simply add or remove objects to the collection as you wish. If you want to make sure that existing objects keep their position in the list, you might want to think about naming conventions like placing a number in front of an object's name so they are sorted by these numbers.

$\endgroup$
2
  • $\begingroup$ +1 but why deleting? Just pick... $\endgroup$
    – lemon
    Commented Feb 6 at 9:26
  • $\begingroup$ @lemon Oh yeah, you're right... when I built that my mind was influenced by the other answer... better with picking, I'll change that. $\endgroup$ Commented Feb 6 at 10:49
1
$\begingroup$

Not sure why I don't have the select geometry node you have, but his should work. enter image description here It simply gets the number of instances in a collection and destroys all but one selected by random

$\endgroup$
2
  • $\begingroup$ You don't have the Select Geometry node because it is a custom nodegroup. The question to which @Nickh129 links to at the beginning is showing a node setup which you can arrange to create a custom group like that. By the way I don't think he was asking for selecting random meshes, just being able to add or delete objects to choose from without the need to adjust the nodetree. $\endgroup$ Commented Feb 6 at 8:17
  • $\begingroup$ Nobody has that node - I hacked the screenshot together in photoshop. But the Collection Info node is a much more elegant way of doing it anyway. $\endgroup$
    – Nickh129
    Commented Feb 6 at 12:19

You must log in to answer this question.

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