SDK: -Lua reset development settings on photo
I have a need in my plugin to reset the adjustmentPanel settings in the Develop module for a group of photos (all photos in my code example). Essentially I want to replicate the functionality of what the Reset button does in the Develop module across many images. None of the functions in the SDK seem to offer the same work as what the Reset button does for even a single photo, but based on some examples I have found in this community it seems like the following should come close enough for my purposes:
local LrApplication = import "LrApplication"
local LrTasks = import "LrTasks"
local LrProgressScope = import "LrProgressScope"
local settings = {
Exposure = 0,
Contrast = 0,
Highlights = 0,
Shadows = 0,
Whites = 0,
Blacks = 0,
Texture = 0,
Clarity = 0,
Dehaze = 0,
Vibrance = 0,
Saturation = 0
}
LrTasks.startAsyncTask(function()
local catalog = LrApplication.activeCatalog()
local allPhotos = catalog:getAllPhotos()
local portionComplete = 0
local progressScope = LrProgressScope({ title = 'Resetting All Photos' })
progressScope:setCaption('Resetting all photos')
catalog:setActiveSources(catalog.kAllPhotos)
LrTasks.sleep(1)
for i = 1, #allPhotos, 1 do
if progressScope:isCanceled() then return end
catalog:withWriteAccessDo("Reset Basic Settings", function()
allPhotos[i]:applyDevelopSettings(settings, "Reset Settings", true)
end, { timeout = 0.5, asynchronous = false })
portionComplete = portionComplete + 1
progressScope:setPortionComplete(portionComplete, #allPhotos)
end
progressScope:done()
end)
This lua code seems to run fine as far as I can tell, but all of the images have the same settings in the adjusmentPanel afterward. Though history on each image does indeed have a "Reset Settings" entry for each. Any help on what may be the issue here or if there is a better way to reset settings on a group of photos (collection, selection, all in catalog) would be greatly appreciated.
Tested on LR 11.4.1 / Mac OS 12.4.1
