Answered
How do I set a layer's category via Python API?
I am trying to use the API to automate processing of a directory containing some images. I need to set the category under the "basic parameters" section. How can this be accomplished?

I am trying to use the API to automate processing of a directory containing some images. I need to set the category under the "basic parameters" section. How can this be accomplished?

Hi,
Here is how you can achieve that :
import substance_sampler as ssa
def main():
asset = ssa.get_selected_asset()
image_to_material_layer = asset.get_layers()[2]
category_parameter = [l for l in image_to_material_layer.parameters if l.identifier == "category"][0]
category_parameter.value = 0 # 0 for Ceramic => it is the index in the list of categories
if __name__ == '__main__':
main()
If you are searching for other methods, you can consult the Python API documentation. Here is how to access it:

Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.