Page MenuHome

Geometry Nodes: Add "Collection Child" node
AbandonedPublic

Authored by Hallam Roberts (MysteryPancake) on Feb 8 2022, 1:50 PM.

Details

Reviewers
None
Group Reviewers
Geometry Nodes
Summary

Based on Alex Rosaman's node and inspired by Right Click Select

This node allows you to retrieve a child within a collection by index. It allows both child collections and child objects to be retrieved.
This helps you navigate collections and sub-collections without having to delete a bunch of geometry.

Retrieve child objectsRetrieve child collections

It would be good to add filtering options, and to add a control to the "Collection Info" node which prevents it from merging subcollections, as this can be confusing.

The naming is also a bit confusing at the moment, any suggestions would help!

Diff Detail

Repository
rB Blender
Branch
temp-childatindex (branched from master)
Build Status
Buildable 20426
Build 20426: arc lint + arc unit

Event Timeline

Hallam Roberts (MysteryPancake) requested review of this revision.Feb 8 2022, 1:50 PM
Hallam Roberts (MysteryPancake) created this revision.
Hallam Roberts (MysteryPancake) edited the summary of this revision. (Show Details)

Great! What does the index accepting a field mean in this case? Can you create temporary collections dynamically?

Great! What does the index accepting a field mean in this case? Can you create temporary collections dynamically?

It seems to be a leftover from the original code, I should probably make it a regular integer instead

  • Remove field support and add storage
  • Sort by name for more predictable results
  • Reorder inputs and move to NODE_CLASS_INPUT
  • Replace dropdown with UI_ITEM_R_EXPAND
  • Fix crash on negative index

While I can see that this node can be useful, I'll probably not allow it without further consideration.
Having nodes that allow us to get one data block (ID internally) based on another might make dependency tracking significantly harder if not even impossible. Maybe some nodes like that could work, but it's unclear where to draw the line yet (e.g. a node to get the parent object might be much more problematic than this one, but maybe not).

A possibly better and more generic alternative would be a node that takes in a geometry that contains instances and an index, and outputs the geometry of the instance at the given index.

While I can see that this node can be useful, I'll probably not allow it without further consideration.
Having nodes that allow us to get one data block (ID internally) based on another might make dependency tracking significantly harder if not even impossible. Maybe some nodes like that could work, but it's unclear where to draw the line yet (e.g. a node to get the parent object might be much more problematic than this one, but maybe not).
A possibly better and more generic alternative would be a node that takes in a geometry that contains instances and an index, and outputs the geometry of the instance at the given index.

At the moment I don't believe this node uses the ID data block. Instead it loops through each element of &collection->children or &collection->gobject, adds them to an array, sorts them by name, then returns an object from that array.

This is the same thing Collection Info does when Separate Children is selected. Collection Info also uses id.name for sorting, just as this node does.

I'm mainly talking about nodes that take some ID as input (e.g. object or collection) and output another ID. Don't think we have any node like that.

A possibly better and more generic alternative would be a node that takes in a geometry that contains instances and an index, and outputs the geometry of the instance at the given index.

This would be good too, although the goal with this node is primarily to make it easier to navigate collections, particularly subcollections, when dealing with lots of structured objects.
Maybe it could be done by introducing a "Collection to Instances" node which would then go into a "Geometry at Index" node, but this would only work for objects and not subcollections.

I can add checks for self reference like in Collection Info and Object Info if this would reduce the amount of possible issues.

(Also I tried to make a parent node, but it never seemed to return anything for some reason)

The Collection Info node with Separate Children already does already what you need afaik.

The Collection Info node with Separate Children already does already what you need afaik.

The issue with Collection Info is the way it combines subcollections into a single instance, which is explained in more detail in the Right Click Select post:

Example: a procedural building is made up of 25 different collections with parts (roofs, corners etc.).
Now the user wants to change the building style. He'd need to change 25 collections to reference the other style.
It would be easier if one could just select a single "master collection" and the subcollections could be sorted out using nodes.

You wouldn't want to put all parts in one collection, because then you could not vary the number of part-variations per collection without breaking the node setup - so nesting collections is unavoidable.
(For example, one style might have more doors or walls than another)

However, right now all subcollections are joined into a single object, after one separation.

Also in the Object case, it's not intuitive nor fast to delete all geometry except for a single object.

The issue with Collection Info is the way it combines all subcollections

If I'm not mistaken, it does not "combine" all subcollections. The information about nested collections is still available. It's just not easily accessible currently. An Instance/Geometry at Index or Instance to Geometry node might solve that.

The issue with Collection Info is the way it combines all subcollections

If I'm not mistaken, it does not "combine" all subcollections. The information about nested collections is still available. It's just not easily accessible currently. An Instance/Geometry at Index or Instance to Geometry node might solve that.

Ah thank you, I understand now. I will work on adding a different node, maybe "Separate Instance Children", to extract child instances from a collection instance.

Hallam Roberts (MysteryPancake) abandoned this revision.EditedFeb 9 2022, 5:07 PM

Moving discussion to https://developer.blender.org/D14064 for now

Hoping this will solve the ID issue mentioned by Jacques Luke

In fact, I still think that this node is needed
I can offer the idea that not only collections, but also objects can have descendants
and you can also search for them using the name
In this case, this node will have more functionality and also give a convenient design.

In fact, I still think that this node is needed
I can offer the idea that not only collections, but also objects can have descendants
and you can also search for them using the name
In this case, this node will have more functionality and also give a convenient design.

I totally agree.
I think it's more intuitive from a user's perspective.