4 Replies Latest reply on Feb 16, 2013 4:57 PM by snahphoto

    change current selection to a subset of current selection

    snahphoto Level 1

      Hi,

      I wonder how I can change/modify a current selection and then have 2 images selected for the new selection. I've got the full path of them 2 images (but I don't have their UUID).

       

      Background:

      From a given selection of images in the filmstrip (not a collection set) a plug-in retrieves full-paths-fileNames into a list for external processing (works fine).

      Error handling: By mistake the user might include some images that should NOT be processed in the previous step. The first differring occurence of mistakenly selected image that should not be processed is caught by a simple comparison to the previous image. Both full-path-filenames are retrieved and displayed in an error message. Then plug-in stops further processing of selected images, Lightroom is back to where it started, the filmstrip selection remains unchanged.

       

      Goal:

      What I want is that upon process stopping that the selection changes to the 2 images that were identified as different.

      Actually differing occurences are caught by Labels and Ratings only.

      if varFLabel ~= varFLabel_comp then
      

      and

      elseif varFRating ~= varFRating_comp then
      

       

      Here is the relevant code I am working on:

       

      LrTasks.startAsyncTask( function()
      local photos = catalog:getTargetPhotos()
      ...
      for j, photo in ipairs(photos) do
                varFLabel = photo:getFormattedMetadata('label')                    --word eg. approved
                varFRating = photo:getFormattedMetadata('rating')                    --number
                if lrItem > 1 then                    -- second pass of 'for ... do'
                          --catch missmatching Labels in selection by user
                          if varFLabel ~= varFLabel_comp then
                                    LrDialogs.message(string.format("Labels missmatch!\n %q Not equal to %q", varFileName_comp, varFileName, "DIFF Labels", "info"), "Labels do NOT match!\nDouble-check your selection!\nStopping task and script!")
      --new selection to show the two differing images in: varFileName_comp varFileName
                                    return          --exit script
                          --catch missmatching Ratings in selection by user
                          elseif varFRating ~= varFRating_comp then
                                    LrDialogs.message(string.format("Ratings missmatch!\n %q Not equal to %q", varFRating_comp, varFRating, "DIFF Ratings", "info"), "Ratings do NOT match!\nDouble-check your selection!\nStopping task and script!")
      --new selection to show the two differing images in: varFileName_comp varFileName
                                    return          --exit script
                          end
                end
                --prepare for next comparison in 'for ... do' 
                varFileName_comp = varFileName
                varFLabel_comp = varFLabel
                varFRating_comp = varFRating
      end
      end)
      
      

       

      Tried to make use of the function setSelectedPhotos but I don't get any results only internal processing errors and don't know how to best proceed.

      I assume this function requires the LrPhotoID derived from the selected Photos table (array).

       

      photos = catalog:setSelectedPhotos( varFileName, varFileName_comp )
      

       

      Edit: This command selects one of the differing images

      return catalog:setSelectedPhotos( photo, {} ) --exit script
      
      

       

      Hope someone can help.

       

      Message was edited by: snahphoto