Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Undo Operations in a Script
#2
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:

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.
Reply


Messages In This Thread
Undo Operations in a Script - by BaconWizard17 - 03-08-2023, 11:57 PM
RE: Undo Operations in a Script - by Ofnuts - 03-09-2023, 04:32 PM
RE: Undo Operations in a Script - by Ofnuts - 03-18-2023, 10:58 AM

Forum Jump: