Automatically apply an mtl override on objects with no material assigned

Hey all,
Maybe I’m missing something, but is it possible to have V-Ray applying a material override that only includes objects with no material applied? That way one can have a decent preview render without all those wonderful object/layer colors messing your GI…
Any thoughts?
Tks!

This should do it:

1. Use this script to select all objects without a shader:
select (for i in objects where i.material==undefined collect i)
2. Invert the selection (Ctrl+I)
2. Create a new layer and add the selection (Add Selection to Current Layer).
3. Activate the Override Mtl feature (Render Setup>Global Switches>Override Mtl) and set it to Exclude Layers.
4. Select the newly created layer.

Instead of layers, you can also create a selection set, and include that into the override.
Run the script below, and you’ll get a “NoMaterial” selection set visible in the override’s include/exclude dialog.

selectionSets["NoMaterial"] = for g in geometry where g.material == undefined collect g

Thanks, guys!
My first attempt was doing just that, using a script to select everything without material and adding them manually. Lele’s solution looks a bit more elegant in that sense, but doesn’t seem to work: the selection set is indeed created, but ti does not select any of the objects, even those I just created for test purposes.
If I use the set outside of the Exclude/Include dialog, it works fine, but doesn’t seem to work in the list (Max2022).

In my case the nodes are assigned (without being selected!) to the selection set.
Once i open the include/exclude list for the override, i can pick the noMaterials selSet from the dropdown, which in turn selects the nodes in the list.
Then i click the add to exclude/include, and i am done.

See the linked capture of the process.

Hum… got it. Thanks for the video, I was going straight to the selection set instead of having it first select the objects.
Thank you once again!