Copy link to clipboard
Copied
LrDevelopController.setValue() doesn't set the Enable* settings controlling the toggle switches of the Develop panels (e.g. EnableDetail), even though .getValue() retrieves the values correctly. A workaround is to use photo:applyDevelopSettings().
Tested on LR 7.4 / Macos 10.13.5.
The test script below demonstrates the problem. Running it produces this output:RackMultipart20180630567081org-7079f549-2b90-44c3-b930-3f8dc8392a15-152658996.png
--[[----------------------------------------------------------------------------
12345678901234567890123456789012345678901234567890123456789012345678901234567890
Tests the Enable* settings with photo:applyDevelopSettings(),
LrDevelopController.getValue() and .setValue().
------------------------------------------------------------------------------]]
local showErrors
if false then
require "Require".path ("../common")
require "strict"
local Debug = require "Debug".init ()
showErrors = Debug.showErrors
else
showErrors = function (x) return x end
end
local LrApplication = import "LrApplication"
local LrDevelopController = import "LrDevelopController"
local LrDialogs = import "LrDialogs"
local LrTasks = import "LrTasks"
local catalog = LrApplication.activeCatalog ()
local getValue = LrDevelopController.getValue
local photo = catalog:getTargetPhoto ()
local setValue = LrDevelopController.setValue
local enableKeys = { "EnableCalibration",
"EnableCircularGradientBasedCorrections", "EnableColorAdjustments",
"EnableDetail", "EnableEffects", "EnableGradientBasedCorrections",
"EnableGrayscaleMix", "EnableLensCorrections",
"EnablePaintBasedCorrections", "EnableRedEye", "EnableRetouch",
"EnableSplitToning", "EnableTransform"}
LrTasks.startAsyncTask (showErrors (function ()
local applyFails, getFails, setFails = "", "", ""
for _, enableKey in ipairs (enableKeys) do
local value = photo:getDevelopSettings ()[enableKey]
catalog:withWriteAccessDo ("test", showErrors (function ()
photo:applyDevelopSettings {[enableKey] = not value}
end))
if photo:getDevelopSettings ()[enableKey] ~= not value then
applyFails = applyFails .. " " .. enableKey
end
local value = photo:getDevelopSettings ()[enableKey]
if getValue (enableKey) ~= photo:getDevelopSettings ()[enableKey] then
getFails = getFails .. " " .. enableKey
end
setValue (enableKey, not value)
if photo:getDevelopSettings ()[enableKey] ~= not value then
setFails = setFails .. " " .. enableKey
end
end
LrDialogs.message ("Testing Results",
"photo:applyDevelopSettings() fails on: " .. applyFails .. "\n\n" ..
"LrDevelopController.getValue() fails on: " .. getFails .. "\n\n" ..
"LrDevelopController.setValue() fails on: " .. setFails)
end))
Copy link to clipboard
Copied
--[[----------------------------------------------------------------------------
12345678901234567890123456789012345678901234567890123456789012345678901234567890
Tries to toggle the value of EnableDetail using LrDevelopController.
------------------------------------------------------------------------------]]
local LrApplication = import "LrApplication"
local LrDevelopController = import "LrDevelopController"
local LrDialogs = import "LrDialogs"
local catalog = LrApplication.activeCatalog ()
local getValue = LrDevelopController.getValue
local photo = catalog:getTargetPhoto ()
local setValue = LrDevelopController.setValue
local before = getValue ("EnableDetail")
setValue ("EnableDetail", not before)
local after = getValue ("EnableDetail")
LrDialogs.message ("Results",
"Before: " .. tostring (before) .. "\nAfter: " .. tostring (after))
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now