3 Replies Latest reply on Jun 16, 2010 2:36 AM by areohbee

    Using LrDevelopPreset in SDK 3.0

    cowboy_bob

      I am importing images and would like to set the Develop Setting to AutoTone automatically using the following code upon import:

       

      catalog:withWriteAccessDo( 'Importing Images Task', function()
               local photo = catalog:addPhoto(filePath)
               --local developPreset = photo:getDevelopSettings()
               local developPreset = app.getDevelopPresetsForPlugin(_PLUGIN)
               local settings = developPreset.getSetting()
               settings.AutoTonality = true

               photo:applyDevelopPreset(developPreset, _PLUGIN)
              end)

       

      This causes an Error with the following message:

      An internal error has occurred: [string "PluginManager.lua"]:73 attempt to call field 'getSetting' (a nil value)

       

      How would I go about creating a valid LrDevelopPreset object to then set AutoTonality = true and pass to applyDevelopPreset() or is there perhaps a better way to automatically set AutoTone upon import via a plugin?

        • 1. Re: Using LrDevelopPreset in SDK 3.0
          areohbee Level 5

          Hi Cowboy Bob,

           

          I'm not sure what's the best way to do what you're doing, but the error is due to the fact that

          getDevelopPresetsForPlugin(_PLUGIN) returns a table not an LrDevelopPreset, unless you pass a uuid too.

           

          Once you get a LrDevelopPreset, remember to use a ':' instead of a '.' when calling 'getSetting'.

           

          Rob

          1 person found this helpful
          • 2. Re: Using LrDevelopPreset in SDK 3.0
            cowboy_bob Level 1

            Thanks Rob, that got me closer and then I just found out I needed to perform the following as well to make it apply to the imported photo:

             

            local preset = LrApplication.addDevelopPresetForPlugin( _PLUGIN, "Auto Tone Preset", settings )
            photo:applyDevelopPreset(preset, _PLUGIN )

             

            to now give:

             

            catalog:withWriteAccessDo( 'Importing Images Task', function()
                      local photo = catalog:addPhoto(filePath)
                      local settings = photo:getDevelopSettings()
                      settings['AutoTonality'] = true
                      local preset = app.addDevelopPresetForPlugin( _PLUGIN, "Auto Tone Preset", settings)
                      photo:applyDevelopPreset(preset, _PLUGIN)

                      end)

            • 3. Re: Using LrDevelopPreset in SDK 3.0
              areohbee Level 5

              Looks good Cowboy .

              Rob