Reputation: 65
Simple problem. I want to change the parent of LayerA to GroupB. The member "parent" of layer is read only, and I can't use pdb.gimp_image_insert_layer because the layer already has been added to image. I also tried removing it first by gimp_image_remove_layer, and it also doesn't work.
Upvotes: 1
Views: 178
Reputation: 8904
I cannot find an API for this in Python. Using image.remove_layer() deletes the layer so it cannot be re-inserted, so the best I can think of is to copy the layer using something like this:
def moveLayer(image,layer,group,position):
layerName=layer.name
layerCopy=layer.copy()
image.remove_layer(layer)
layerCopy.name=layerName # Can't have two layers with same name
image.insert_layer(layerCopy,group,position)
return layerCopy # this one has a new ID
This said, I've written many Python scripts and never needed to change a layer parent, so maybe there is a way to avoid doing this...
Upvotes: 1