Set a list of some sort of things a certain color?

So, I have an actor that has a lot of nodes and I want to color some of them the same color, but I don’t want to do node.setcolor a lot of times so it doesn’t take up space. How would I make a list or tuple or something so that the names of objects inside them all get colored a certain color?

First of all, based on your description I presume that the sub-parts of the Actor are included in that Actor’s model-file, rather than being objects that you parented to it yourself.

Given that, do the relevant sub-parts have anything in common? Do they all have a specific tag, or names that follow a simple pattern, in particular? If so, you might use NodePath’s “findAllMatches” method (as described here) to find all of the relevant sub-parts, and then iterate over the resultant collection and apply your colour.

Otherwise, would you please provide a bit more detail regarding your specific situation?

FWIW you can call setColor directly on the return value of findAllMatches.

Ooh, that’s quite neat! I wasn’t aware of that, I believe, so even just for myself, thank you. :slight_smile:

Yeah, findAllMatches() returns a NodePathCollection, which is iterable like a list but also has some convenience methods that apply to all nodes in the collection: … ection.php

Very neat, and potentially quite useful. :slight_smile:

I did this before once too. What you need to do is create a list of the node names you’d like colored, next you will iterate through each list entry and use .find() on the Actor, check if the node does not equal None, and color it.