09-11-2020, 02:56 PM
I have channels, named 0 to 9.
To create layers 0 to 9, I can repeat the code, changing "0" to "1", "2", etc. and it works perfectly.
I would like to make a loop to carry out this process, but everything I have tried has given me errors and searching the internet hasn't provided any examples for me to follow.
An example of how to do this (ideally with a detailed explanation) would be appreciated and perhaps would help others.
david.
To create layers 0 to 9, I can repeat the code, changing "0" to "1", "2", etc. and it works perfectly.
I would like to make a loop to carry out this process, but everything I have tried has given me errors and searching the internet hasn't provided any examples for me to follow.
An example of how to do this (ideally with a detailed explanation) would be appreciated and perhaps would help others.
david.
Code:
#create layer with 0 as mask
pdb.gimp_image_select_item(image,CHANNEL_OP_REPLACE,channel0)
layer_add = pdb.gimp_layer_new_from_drawable(layer,image)
pdb.gimp_image_insert_layer(image,layer_add,None,0)
pdb.gimp_item_set_name(layer_add,"0")
pdb.gimp_layer_create_mask(layer_add,ADD_MASK_SELECTION)
mask = pdb.gimp_layer_create_mask(layer_add,ADD_MASK_SELECTION)
pdb.gimp_layer_add_mask(layer_add,mask)
pdb.gimp_image_remove_channel(image,channel0)