Assign Objects to Individual Layers

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.

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

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

1 Like

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.

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

1 Like

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

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

Hi Willem,

I am replying to this thread which is from 2014, but I would greatly appreciate if this “ObjectsGroupsToNamedLayer.rvb” could be made available again. This is a fantastic script idea which would be a huge help for my current project. Would you consider making this available again for use with Rhino 7? I am a long time user, but just joined this forum.

-Jon

Hi Jon - it looks like the script is available from

-Pascal

Hi Pascal,

The script “ObjectGroupsToLayer” is available and works great, but does not label the layer with the Rhino Object Name, instead OBJ_01, OBJ_02, etc. The script that appears to be unavailable is “ObjectGroupsToNamedLayer.rvb” will create layers and will name them exactly as the Rhino object name. That is if I’m understanding the description correctly.

-Jon

Ah, yes, ok- I can probably make something that works if Willem is busy, which I think he very often is…
@JD12 - is the idea

  • find all groups
  • make a layer for each group’s name
  • put the objects from each group onto the corresponding layer of their top-level group (if in more than one)
    ?

-Pascal

Wow, that would be great! Much appreciated.

Actually what I was hoping for was a script that allow me to take a bunch of uniquely named objects and then create and place them on their own layer. The layers would be named exactly the same as the object. Does that make sense?

-Jon

Hi Jon - see if this is it -

ObjectsToLayerByName.py (385 Bytes)

If the layer exists, then the object is put there, if not the layer is created - this could lead to multiple objects per layer as it stands now…
Also, this acts on selectable objects - not hidden or locked - it can do those too, or on a user selection - it’s all easy enough to change.

To use the Python script use RunPythonScript, or a macro:

_-RunPythonScript "Full path to py file inside double-quotes"

-Pascal

2 Likes

Works perfectly! Tested it on a few different files. Can’t thank you enough Pascal!

All the Best,

-Jon

1 Like