Really FUN script request that might actually be useful for others

What I’d like to do is select a group of objects. Run script.

-Prompt for number x of layers
-Make x layers
-Assign each object in the selection randomly to one of the layers. I know true randomization is difficult but someone clever can probably figure something out.

In my case I’d like to use it for floors, which are made of hundreds of planks. I’ve got a handful of different plank images. I’d like to assign a different plank materials to each layer… and if the planks could all go on the layers randomly I would end up with beautiful natural looking floors.

There’s lots of cool things you could do with this though. At Christmas time I did some strings of lights and this would have been helpful for randomizing the bulb colors.

You can try this quick hack on for size - it will also add random colors to the created layers and name them sequentially - you can change the naming convention by changing the prefix and/or separator at the top of the script. Let me know how it works.

–Mitch (960 Bytes)

Nice moody render R. I’ve got a Santa your could put in the pilothouse if you want. I need to work on my fog, is this Octane? I got a bit of a foggy effect with glare and gloom but it looks like you have a volumetric fog in you model.

Thanks for the script H!


It’s Maxwell, and yes, volumetric fog. The noise is just from not letting the render resolve fully. When I let it run out and clean up it didn’t actually look snowy… More just foggy and wet. The noise kindof sold the look I think and only took 5 minutes to run, so that was nice.


Winner. Gold star for you today. This would have been basically impossible. See below.

This would have been really annoying to do manually. Like give it to an intern and say “see you in three hours” and it probably still wouldn’t look as good.

You can see I ran into a couple hiccups.

  1. Trimming the individual surfaces and deleting the extras… lead to a couple oopses and was tedious. A “trim group” that would trim all of them like a multisurface would be awesome. No idea on the complexity of realizing that but it would make this method truly efficient as a design tool vs. something you do once at final render time.

  2. I’ve got a texturing issue on the surfaces that got trimmed. I put a planar map on them before I arrayed/copied the first plank and the surface mapping didn’t really stay put relative to the original surface after trimming. What did I do wrong here?

P.S. the pastel colours are pretty. Nice touch. They’re obviously not random. EDIT: They are random. Interesting. Looks like randomization is easy too.

I modded it slightly to do this:

prefix=rs.GetString("Layer name prefix?","RandomLayer")

The only other comment I would have is to automatically put the new layers as sublayers of whatever layer my selected objects are on.

Obviously this is only one mouse drag but, hey, it’s probably really easy to integrate so why not. I did some helpfile searching but I’m over my head at this point.

As the original objects could be on different layers, you would have to choose under which layer to put the sublayers - unless you’re always sure that all selected objects will be on only one layer to begin with. It is possible to just grab the layer of the first object in the list of selected objects and use that layer; other possibility would be to create a new “master” layer and throw all the sublayers under that. Which would you prefer?


What happens if we check if they’re all on the same layer, and if so, do it that way. If not, put them under the active layer? Or is that too sneaky from a user perspective.

I.e. For myself, if my objects and layers are tidy, then the script would keep the pattern going. If my objects are a mess and all over the place, then I can activate the layer I want the random layers in, and they’ll go there.

If this is getting too involved then don’t sweat it.

No, that’s no problem, just adds some overhead in that you have to check the layer all selected objects are on - might slow the thing down somewhat if you have thousands of objects and all are on the same layer except the last one… but otherwise presents no real problem.

Here ya go… (1.3 KB)


I modified it as well.
Now it will create a new parent layer, if wanted,
And if your number of random layers is the same as the selected objects, you will no longer get empty layers.
Also the layers will get sorted in the right order by inserting leading zeros. (1.6 KB)

@Helvetosaur something’s come up in using this a bit more.

Situation is that when changing trims, like moving a staircase. No real way around just populating the hole with planks. Would be nice to be able to move the fresh planks onto the parent layer, then run the script again, and providing I type in the same prefix, could we check if the children exist already and then use existing layers instead of making new ones?