Hello, I can’t seem to find a way to trigger the “Use as Master” command for a special layer in a script. Is there a specific function for this, or do I need to do this process more manually?
That command is in the Layer panel, so it is a bit trick to get to from a script. But it is not difficult to do that manually. Depending if you still need the previous master layer.
layer.parent.layers[layer.associatedMasterId] = layer
with keeping the previous layer
glyph = layer.parent oldMaster = glyph.layers[layer.associatedMasterId] glyph.layers[NSString.UUID()] = oldMaster layer.parent.layers[layer.associatedMasterId] = layer
Yes, thank you, that’s pretty much exactly what I wrote as a workaround
Why would that be a workaround?
Because simply writing Layer.useAsMaster() would be far simpler.
Right. Would you expect that this method would preserve the original layer?
Yes, like the command in the layers panel. Use the selected layer as the master layer, and make the master layer a backup layer.
I’m not sure whether it would be useful to add a parameter to the method to define whether the selected layer should be switched with the master layer, meaning the layer still stays an alternate, but the shapes get copied from the master layer.