Get and set parameters for a layer from python

Get and set parameters for a layer from python

What to do when you need to set and get a parameter

Once you have access to a element and want to change one of it's parameter,using the usual print(dir(myLayer)) method or Use Oil.docMe() to get a view of the possibilities a best way to have an idea of what an object can do Read More , we can see a few properties of interest: for example we can set the label of the element
myLayer = script.parentElement.layers[0]
myLayer.label = "myLayer"
will rename the first layer in the element Tree
myLayer = script.parentElement.layers[0]
myLayer.activation.set(False)
will deactivate the layer
Now the first layer named "myLayer" could also be retrieved with:
myLayer = script.rootElement.layers["myLayer"]

See Also: