Quantcast
Channel: Adobe Community : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 238792

Add selected photos to new collection

$
0
0

Probably a newby question, but how can I add selected photos to a new collection.

 

Reading the SDK doc:

  1. catalog:getTargetPhotos()
    Return value
    (array of LrPhoto) The photos.
  2. collection:addPhotos( photos ):
    Parameters
    photos (array of LrPhoto) The photo objects.

 

To me catalog:getTargetPhotos() returns a array of LrPhoto and collection:addPhotos askes for an array of LrPhoto.

 

Yet I always get "An internal error has occurred: assertion failed".

 

Where do I go wrong?

 

I'm running the code below on an Windows XP SP3 machine with Lightroom 3.6

 

local LrTasks = import 'LrTasks'

local catalog = import "LrApplication".activeCatalog()

local LrFunctionContext = import 'LrFunctionContext'

local LrProgressScope = import 'LrProgressScope'

local LrDialogs = import 'LrDialogs'

 

local myLogger = import 'LrLogger'( 'AddImages' )

myLogger:enable( "logfile" )

 

function AddImagesToCollection()

 

    LrTasks.startAsyncTask(function()

 

        catalog:withWriteAccessDo( "Test", function()

 

local test1Collection = catalog:createCollection( "Test_1 Collection", nil, true )

 

local cat_photos = catalog.getTargetPhotos()

local nCountSelected = #cat_photos

myLogger:trace( 'number selected photos:', #cat_photos)

 

test1Collection:addPhotos{ cat_photos }

        end)

 

    end)

end

 

AddImagesToCollection()

 


Viewing all articles
Browse latest Browse all 238792

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>