Append text to end of selected layer

I want to create a button that will add some text to the end of whichever layer is highlighted.

Keyshot lets you apply materials by layer using an automated tool based on layer name. So I figured that would help speed up how layers are named.
Select the layer, click my “chrome” button and it adds “_chrome” to the end of that layer. Select next layer and click my “chrome rough” button and it adds “_chromeRough” to the end of that layer.
Just a couple examples. I’d make a Bunch of buttons to apply common names.

I’m not sure where to start with that.

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

To create a button for a script look here.