Copy link to clipboard
Copied
I want to experiment with applying develop adjustments from a plug-in. noticed the photo:applyDevelopPreset( preset, plugin ) function.
Question:
Is there a way to create a preset on the fly within the plug-in, for example a preset for setting the Exposure2012 to +10.
A little piece of code would be appreciated much!
Copy link to clipboard
Copied
preset = LrApplication.addDevelopPresetForPlugin( _PLUGIN, "My Groovy Preset", { Exposure2012 = .3 } ) -- no catalog write access required.
photo:applyDevelopPreset( preset, _PLUGIN ) -- catalog write access required.
Note: develop preset will be applied at Lr's leisure in the background (after returning from catalog write access method), so if you are depending on preset settling in, you need to add some logic after applying.
Beware: assuring auto-toned values have settled, so you can make adjustments to auto-toned values, is particularly problematic. There are similar problems with auto/custom white-balance, lens corrections, ...
Copy link to clipboard
Copied
Rob, THANK YOU!!!!!!!!!
Great,this is awesome!
Copy link to clipboard
Copied
Hi guys im working on my first plugin, excuse me my poor knowlage. i use code
"
local function setPreset ()
local LrApplication = import 'LrApplication'
local catalog = LrApplication.activeCatalog()
catalog:withWriteAccessDo( 'setPreset', function()
local preset = LrApplication.addDevelopPresetForPlugin( _PLUGIN, "___Dummy___", { Exposure2012 = 1.2 } )
photo:applyDevelopPreset(preset, _PLUGIN)
end)
end
"
i recive error :
attemp to index global 'catalog' a nil value.
why is that happening?
Copy link to clipboard
Copied
Is that the complete script you're executing, or is it an excerpt? The error you're getting, "attemp to index global 'catalog' a nil value", wouldn't arise from the code fragment you posted. Without seeing a complete script, it's hard to know what's going on.
Copy link to clipboard
Copied
thank you for your response John
yes, thats all i have, What else i should include in code? sorry for beeing nooby
Copy link to clipboard
Copied
If you were expecting catalog to be available upon return from the function posted - it won't be: function's locals are out of scope in context external to the function where they're declared, so catalog will be expected in the global environment instead (everywhere but inside that function), but it's not - thus the error, probably.
-- in other words:
local catalog
local function yada()
catalog = LrApplication.activeCatalog()
end
yada()
LrDialogs.message( tostring( catalog ) )
-- works, whereas
local function yada()
local catalog = LrApplication.activeCatalog()
end
yada()
LrDialogs.message( tostring( catalog ) )
-- will give the error you're getting
Either that, or there was a typo somewhere... ![]()
PS - you may want to spend some more time reading that lua manual
.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more