Assign Objects to Individual Layers


#1

Hi,

Does anyone know of a way either existing in Rhino 5 or with script to automatically assign all objects in a scene to a new layer of its own?

I ask because if you import a 3dm into Keyshot (not using the plugin within Rhino), the objects are either grouped by material as assigned in Rhino or by layer. This is less than ideal if you plan to animate and want to move objects, because as far as I can tell they cannot be ungrouped.

So a simple solution would be to assign each object to its own layer. It’s a bit brute force but it would solve the problem.


Assign Materials to Individual Objects Randomly
Assign different layers/materials to all items with one click
(Willem Derks) #2

Hi Mathew,

This script will distribute all select-able objects (not hidden or locked) to individual layers with a random color and sequential name.
ObjectsToLayers.rvb (1 KB)

EDIT: I created an updated script as per request in another topic:

To run it you can drag-drop if over rhino.
Be aware that with many objects it can be time consuming; make sure to keep a good backup copy of your file.

Let me know what you think.

-Willem


#3

Perfect! Exactly what I wanted, thanks very much Willem!


#4

Any way the layers can be named based on the object? Im importing a bunch of STLs into a file and need them to be randomly colored and all on their own self titled layer.

The original script you posted is fantastic, but for me its only halfway there.


(Willem Derks) #5

Hi Ted,

Have a look at this version.
It will try of the (objects) for a layer have a name, and if so give the layer that name.
If there already ois a layer with that name; it is numbered.

ObjectsGroupsToNamedLayers.rvb (2.8 KB)

HTH
-Willem


#6

Hi Willem,

Sorry for bringing up an old tread. The script you wrote is almost what I really need, but instead of assigning the individual objects into layers, is it possible to assign layers based on the groups?

It doesn’t sound very hard, but my scripting is terrible. I don’t even now where to start! Your help would be greatly appreciated. Thanks!

-Eric


(Willem Derks) #7

Hi Oscire,

My time is limited at the moment, so I cannot be of help.
Does the script not do what you need: grouped objects to layers?
Can you elaborate on what the exact function needs to be, it might be someone else can be of help.

-Willem