applyDevelopSettings fails: ?:0: attempt to call up value '?' (a nil value)
I am trying to write a first Lightroom plugin to automatically crop and rotate images. I should be able to work out the crop settings (assuming I can translate to LR values later, and avoid limitations on setting crop values from the SDK), but I'm getting stuck at a more basic level applying any develop adjustment at all to any image. Being new to LUA does not help ![]()
Whether I use something like photo:applyDevelopSettings({Exposure = 0.1}) or LrDevelopController.setValue("CropAngle", "0.1"), in both cases this fails with:
?:0: attempt to call up value '?' (a nil value)
Am I missing something in the way this call is formatted? Or do I need a full set of settings from getDevelopSettings(), or a preset or something else? In case it makes a difference, the target photos do not have any existing develop settings beyond import.
My full plugin that fails:
-- Access the Lightroom SDK namespaces.
local LrApplication = import 'LrApplication'
local LrDevelopController = import 'LrDevelopController'
local LrTasks = import 'LrTasks'
local LrDialogs = import 'LrDialogs'
function MyPluginTopLevel()
-- Main top level callback
LrTasks.startAsyncTask(MyPluginTask, "MyPlugin main task")
end
function MyPluginTask()
local catalog = LrApplication.activeCatalog()
catalog:withWriteAccessDo("MyPlugin test", MyPluginApplyParams, {timeout = 10})
end
local function MyPluginApplyParams(context)
local catalog = LrApplication.activeCatalog()
local selectedPhoto = catalog:getTargetPhoto()
if (selectedPhoto == nil) then
LrDialogs.message( "Error: cannot get selected photo", nil, "info" );
return nil
else
-- EITHER OF THESE TWO NEXT LINES FAILS:
-- LrDevelopController.setValue("CropAngle", "0.1")
selectedPhoto:applyDevelopSettings({CropAngle = "0.1"})
end
end
-- Call top level:
MyPluginTopLevel()