2 Replies Latest reply on Nov 15, 2014 8:16 PM by areohbee

    Some thoughts / questions on createVirtualCopies() LR5


      I've been playing a little with the createVirtualCopies funciton in LR5.


      First adding the createVirtualCopies() function is great!

      Thought / wise: could there be a similar function in the LrPhoto class, so that based on a photo a Virtual copy is created?

      Then I'm not dependant upon any active selection.


      Some questions:

      1. Why is it a catalog namespace?
        Now as a plug-in developer I have to deal with selected photos and I would love to create a Virtual copy on a particular photo object as I like.
      2. And what happens if the user selects a different photo when the plug-in is running?
      3. What is the return value?
        At least it is not a properly LrPhoto object.

      I did a little test:



      local LrDialogs = import 'LrDialogs'
      local LrTasks = import 'LrTasks'
      local LrFunctionContext = import 'LrFunctionContext'
      local LrApplication = import 'LrApplication'
      Name          inspect
      Purpose          module for listing a table
      Source          https://github.com/kikito/inspect.lua
      local inspect = require 'inspect'
      LrFunctionContext.postAsyncTaskWithContext( "CreateVirtualCopyTest", function( context )
          LrDialogs.attachErrorDialogToFunctionContext( context )
          local catalog = LrApplication.activeCatalog()
       local activePhoto = catalog:getTargetPhoto()
       LrDialogs.message( inspect (activePhoto:getDevelopSettings()) )
       if activePhoto ~= nil then
       local virtualCopy = catalog:createVirtualCopies( "CreateVirtualCopyTest" )
       LrDialogs.message( inspect (virtualCopy:getDevelopSettings()) )
       LrDialogs.message( "No photo selected! Please select a photo" )
      end )


      Any thoughts?


      (Example based on code of Rob Cole.)

        • 1. Re: Some thoughts / questions on createVirtualCopies() LR5
          areohbee Level 6

          dhmc05 wrote:


          Any thoughts?

          Poor design (sorry Adobe).


          There are a number of new functions which bypass the catalog write methods (which is convenient) but are tied to the Lr user interface, e.g. library view mode, or develop module, which is bad - especially bad since there is no way to:


          A. Tell which module / mode Lr is in.

          B. Force which module / mode to be in.

          C. Assure photos are targeted, even if being filtered, or are underlings in a stack..


          I hope somebody who knows what they're doing with the SDK sorts this mess out before releasing Lr5 SDK.



          • 2. Re: Some thoughts / questions on createVirtualCopies() LR5
            areohbee Level 6

            one error in your code:


            it should be:


            local virtualCopiesArray = catalog:createVirtualCopies...


            i.e. return value is an array of photos.


            Note: this function is ONLY reliable in library module, not develop module.


            I strongly recommend that you check each photo in the array to assure it is a virtual copy as you expect. Lr will sometimes return photos that are NOT virtual copies of the master as you were hoping for, e.g. if in develop module.