Shortcut for Creating a new layer

Hey,
I would like to know if there is any shortcuts for creating a new layer in Silhouette Roto module? If its not there, it’s highly recommended to be there!

Thanks!

Edit your keybinds.py file and bind a key to this function:

def add_layer():
    layer = Layer(uniqueLabel("Layer"))
    fx.beginUndo("Create Layer")
    activeNode().property("objects").addObjects([layer])
    fx.endUndo()
1 Like

Hi! I tried the solution you suggested - it works, but unfortunately I have to manually initialize the keybinds through the script editor - maybe I should add something else to your code? And tell me how to make the newly created layer active? While you have to do it manually.

To select the new layer:

def add_layer():
    layer = Layer(uniqueLabel("Layer"))
    beginUndo("Create Layer")
    activeNode().property("objects").addObjects([layer])
    select([layer])
    endUndo()

To make your own external keybinds file, check out Katie and Magno’s KMFX scripts collection. They have examples of how to add user keybinds and actions without modifying the built-in scripts.

2 Likes

You are great man! tanks a lot.

Hi! I did everything according to the instructions in the video about adding custom scripts, added a variable, added code to custom key assignments. Unfortunately, you need to manually run the user keybinds from the script editor in order for the hotkey to add a new layer to work, otherwise the console writes:

 Traceback (most recent call last):
  File "C:/Users/Mike/KMFXscripts\user_keybinds.py", line 84, in add_layer
    layer = Layer(uniqueLabel("Layer"))
NameError: name 'Layer' is not defined

If you open user keybinds in the script editor and run - the hot keys for adding a layer work, the layer is selected, but the layer remains inactive (there is no checkmark) and if you immediately start adding shapes - they are created in a new layer (the one added by the hotkey)
Can you please tell me - is there a code that makes the newly created layer active?

It sounds like you may have forgotten the __init__.py file in your custom script dir which makes everything in there run automatically.

When run from the script editor, did you add from fx import * at the top, since Layer (and uniqueLabel) are both in the “fx” module.

Thanks! Now the hotkey for the new layer works.
You will be very helpful if you tell me the code for the newly created layer to become active.
Now, when adding with the help of a hotkey, the tick of the layer activity must be set manually
image

Oh, just do this:

setActiveLayer(the_layer)

Thanks! setActiveLayer(layer) works fine