I am new to developing on the Lightroom SDK and am trying to build a script to add keywords to a catalog. Here is the contents of the current script:
local LrApplication = import 'LrApplication'
local LrDialogs = import 'LrDialogs'
local catalog = LrApplication.activeCatalog()
GKMenuItem = {}
function GKMenuItem.runProcess()
catalog:withWriteAccessDo("SetKeywords",GKMenuItem.setKeywords() )
end
function GKMenuItem.setKeywords()
local test='Default'
local catPhotos = catalog.targetPhotos
local myKeyword = catalog.createKeyword( 'XYZA: test', {}, true, nil )
for _, photo in ipairs( catPhotos ) do
-- Loop through each of the photos.
-- photo.setKeyword(myKeyword)
LrDialogs.message(test)
end
end
import 'LrTasks'.startAsyncTask( GKMenuItem.runProcess )
The problem I have is that I get an 'Assertion Failed!' message for the createKeyword statement whenever this is run. I've tried a lot of variations without success. Using Lightroom 3.6 on OSX Lion 10.7.4.
Any ideas would be appreciated!
Thanks
Glyn
You are calling the function and passing it's result, what you should do is pass the function proper so with-write-access-do can call it.
i.e.
catalog:withWriteAccessDo( "SetKeywords", GKMenuItem.setKeywords )
instead of
catalog:withWriteAccessDo( "SetKeywords", GKMenuItem.setKeywords() )
North America
Europe, Middle East and Africa
Asia Pacific