View Full Version : Select every nth surface

08-10-2017, 10:11 AM
Hi everyone,

I have a project with 2,100 different materials. I need them all to have 1 of 5 diffuse colors, randomly assigned. Does anyone know of a script that can select every nth material in the surface editor?

All of my materials are sequentially numbered so if anyone knows of a way to select materials based only the last number in the name, that would work as well. Right now I can put a 2 in the pattern box but unfortunately that would select 2, 12, 20, 21, 22, 23, 24... etc etc. I would want it to only select those that end in 2, so 2, 12, 22, 32, 42, etc.


08-11-2017, 09:33 AM
I don't think there's any programmatic way to control the Surface Editor. In LScript, there's no ability to change Surface attributes that I can see.

I'm not sure the effect you're after, but the "Word Cloud" type of scenario in your prior post seems to be the goal. It's too bad you can't (or didn't) use Instances, since then you can randomize the material on an instance-by-instance basis using nodes. Attached is a sample scene which creates the "Word Cloud" type of grouping with two point clouds created in Modeler using Random Points, selecting half of them using MG_Random_Selected_MD.ls which were cut-n-pasted into Layer 3. The Layer 2 instances are not rotated, while the Layer 3 instances are rotated 90 degrees on the Bank channel.

In the Surface Editor, a node network uses Random Scalar seeded with the Instance Index along with a Gradient to assign one of five Colors for each Instance.

The node network assigns random Luminosity, Diffuse, Specular, Glossiness and Transparency using a Random Scalar seeded by the Instance Index multiplied by a prime number that I chose differently for each channel. That *should* result in a completely random material for each separate instance with no duplicates (I think!).

As I said, I'm not sure it's what you're after. Good luck!

137644 137645 137646



08-11-2017, 10:13 AM
This script doesn't select random surfaces, it uses polygon selection to then randomise the surface properties, not sure if it's useful or not to you:


Erik did a video on its use here:


08-11-2017, 04:03 PM
Thanks everyone,

Neither of those solutions is quite what I am looking for but in the end I was able to steer the client into a different direction so it all worked out. Once we finalize everything I'll post it for you all to see (pending client approval of course).