Append text to end of selected layer

Hi @kalamazandy,

here is something you can try from the _EditPythonScript (editor):

import Rhino
import scriptcontext

def DoSomething():
    # text to append to layer name
    suffix = "_Chrome"
    
    # get selected layers or exit if none found
    rc, indices = scriptcontext.doc.Layers.GetSelected()
    if not rc: return
    
    # try to apply suffix to layer names
    for index in indices:
        layer = scriptcontext.doc.Layers[index]
        new_name = layer.Name + suffix
        
        # skip if invalid name
        if not Rhino.DocObjects.Layer.IsValidName(new_name): continue
        
        # assign suffix only if not already assigned
        if not layer.Name.endswith(suffix):
            layer.Name = new_name
        
DoSomething()

To create a button for a script look here.

_
c.