ChangeLayer - change into a sublayer?

Hello,

I am trying to have within the “ChangeLayer” command and in the option to create New Layer… a Sublayer.
I do not know what to write so it can direct my objects into a sublayer. Is it possible at this moment?
For example, I wish to move some texts to the sublayer TEXT. This sublayer, is under a “Master” layer.
Within the command I want to create the new Master layer and also the sublayer TEXT.

Master
-TEXT

The idea is that I wish to create a macro button. I will select the texts that I have in the model space, and with this group of commands, the texts will move into the new sublayer TEXT.

Hope it is understandable…

Thank you,

So, if i understand correctly, you want to create a new (empty) master layer with some name, and then a sublayer of that new layer with the name Text - then throw all your selected text objects into that sublayer - is that right?

I think that’s only possible with a script currently…

Something like this:

import rhinoscriptsyntax as rs

def ChangeTextToNewSublayer():
    objs=rs.GetObjects("Select annotations to change layer",512,preselect=True)
    if not objs: return
    
    while True:
        newName=rs.GetString("New parent layer name?")
        if not newName: return
        if rs.IsLayer(newName) and rs.ParentLayer(newName)==None:
            resp=rs.MessageBox("Parent layer name already used!",49)
            if resp != 1: break
        else:
            p_layer=rs.AddLayer(newName)
            t_layer=rs.AddLayer("Text",parent=p_layer)
            rs.ObjectLayer(objs,t_layer)
            break

ChangeTextToNewSublayer()

–Mitch

1 Like

Thank you! We will try this