Copy link to clipboard
Copied
Hello everybody,
I am new to the world of Lua development and plugins with the Lightroom SDK (version LrC_11.0_202110120910-0bccc70d.release_SDK)
I'm trying to make a plugin that allows you to retrieve a collection from its id, but I get the following error:
Can't get collection information after creating collection inside the same withWriteAccessDo function
Here is my program:
local Require = require "Require" .path ("../debuggingtoolkit.lrdevplugin").reload ()
local Debug = require "Debug" .init ()
require "strict"
local LrApplication = import 'LrApplication'
local LrDialogs = import 'LrDialogs'
local LrTasks = import 'LrTasks'
local function main ()
local catalog = LrApplication.activeCatalog ()
local collections = catalog: getChildCollections ()
LrDialogs.message ("Collection list", catalog: getCollectionByLocalIdentifier ("387") .. collections [1]: getName ())
Debug.pauseIfAsked ()
end
LrTasks.startAsyncTask (Debug.showErrors (main))
My problem is caused by this line :
LrDialogs.message ("Collection list", catalog: getCollectionByLocalIdentifier ("387") .. collections [1]: getName ())
Can you explain to me how to do it please because I do not understand this error well?
I thank you in advance.
Arno
Copy link to clipboard
Copied
That one threw me for a bit. The problem is with this expression:
catalog:getCollectionByLocalIdentifier ("387")
That method takes a number as an argument, not a string. It's a LR bug that it throws that weird error message when you pass a string. So try this:
catalog:getCollectionByLocalIdentifier (387)
Copy link to clipboard
Copied
omg I had already tried this fix, logical, but I had the error "assertion failed" because I had written catalog: getCollectionByLocalIdentifier (387) .getName () out of habit of having other languages :'(
Thx John! 🙂