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

create a preset in lua module

New Here ,
Jul 29, 2013 Jul 29, 2013

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!

TOPICS
SDK
2.2K
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 29, 2013 Jul 29, 2013

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, ...

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
New Here ,
Jul 30, 2013 Jul 30, 2013

Rob, THANK YOU!!!!!!!!!

Great,this is awesome!

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
New Here ,
Nov 30, 2013 Nov 30, 2013

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?

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 ,
Nov 30, 2013 Nov 30, 2013

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.

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
New Here ,
Dec 01, 2013 Dec 01, 2013

thank you for your response John

yes, thats all i have, What else i should include in code? sorry for beeing nooby

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 ,
Dec 02, 2013 Dec 02, 2013
LATEST

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 .

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