Probably a newby question, but how can I add selected photos to a new collection.
Reading the SDK doc:
- catalog:getTargetPhotos()
Return value
(array of LrPhoto) The photos. - 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()