Not as far as I know... But in general , scripts know what they are doing (and would have to keep an accurate track if how many undo-worthy steps have been performed, even across loops).
In your case(*), you can do a gimp_layer_new_from_visible() and pass the resulting layer to the export API. It seems that you don't even need to add the layer to the image:
Remembering which layers have been made visible/invisible and restoring their state is trivial.
(*) In more complicated cases, you just duplicate the image, do your thing, and throw away the copy... This may be faster (and unexpectedly take less RAM) because you can totally disable the undo mechanism.
PS: This looks a lot like what my ofn-export-layer-combinations does... feel free to steal code.
In your case(*), you can do a gimp_layer_new_from_visible() and pass the resulting layer to the export API. It seems that you don't even need to add the layer to the image:
Code:
layer=pdb.gimp_layer_new_from_visible(image,image,'##IMGUR##')
pdb.file_png_save2(image,layer,file,file,False,3,True,True,False,False,False,False,True)
gimp.delete(layer)
Remembering which layers have been made visible/invisible and restoring their state is trivial.
(*) In more complicated cases, you just duplicate the image, do your thing, and throw away the copy... This may be faster (and unexpectedly take less RAM) because you can totally disable the undo mechanism.
PS: This looks a lot like what my ofn-export-layer-combinations does... feel free to steal code.