Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
2

Lightroom SDK: LrDevelopController.setValue() doesn't work with Enable* settings

LEGEND ,
Jun 30, 2018 Jun 30, 2018

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.pngRackMultipart20180630567081org-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))
159
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 02, 2018 Jul 02, 2018
Thanks for looking into this.   You're seeing the toggles in the UI change and the history entries due to the call to photo:applyDevelopSettings(). Here's a simpler script that tries and fails to toggle the value of EnableDetail using LrDevelopController:

--[[----------------------------------------------------------------------------
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))

When I run it, the toggle in the UI doesn't change, there's no history entry, and the script shows:

RackMultipart2018070282424i727-a4d87763-5725-43d9-9fd4-4680de070013-1042211971.png
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jul 02, 2018 Jul 02, 2018
Hi John,

I ran your script and i am also getting the same error dialog as you.

Although, I also see that the script actually works since there are corresponding entry in the History table and UI also gets updated. Can you please confirm the same.

Is it that the changes are actually getting applied successfully, but when you retrieve it again for comparing it is returning the old value ? (and hence the dialog error)

-ragrawal
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 03, 2018 Jul 03, 2018
LATEST
Thanks for the update.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jul 03, 2018 Jul 03, 2018
Hi John,

I went through the setValue/getValue code. Seems the setValue doesn't support the case when the value is not a number and hence can't be used to enable/disable the panels.
We are looking into this. Thanks for reporting.

-ragrawal
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines