remove Photos form collections

New Here ,
Jul 03, 2022 Jul 03, 2022

Copy link to clipboard

Copied

Hello 

My solution for remove selected photo

local catalog = LrApplication.activeCatalog()

local photos = catalog:findPhotos {
    searchDesc = {
        criteria = "pick",
        operation = "==",
        value = -1
    }
}

catalog:withWriteAccessDo('with', function( )
    local collection = catalog:getCollections()
    collection:removePhotos( photos )
end, {timeout = 30})

But nothing happening when I execute code.

Please help me! What is wrong with this code?

TOPICS
macOS , SDK , Windows

Views

43

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 03, 2022 Jul 03, 2022

Copy link to clipboard

Copied

[This post contains formatting and embedded images that don't appear in email. View the post in your Web browser.]

 

   local collection = catalog:getCollections()
   collection:removePhotos( photos )

 

The method catalog:getCollections() doesn't exist. There is catalog:getChildCollections(), but it returns an array of collections, not a single collection.

 

I'm guessing you're not using a debugger, since if you were, you'd see an error message like:

johnrellis_0-1656890049213.png

 

Without a debugger, LR sometimes displays Lua errors, sometimes not.

 

You should use either my Debugging Toolkit or the Zerobrane IDE.  Zerobrane IDE is a full-featured IDE for Lua, but my Debugging Toolkit better handles LR's specific tasking architecture.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 04, 2022 Jul 04, 2022

Copy link to clipboard

Copied

Thank you for your advice! I will try to use your  Debugging Toolkit.

 

 

| The method catalog:getCollections() doesn't exist.

It is strange because I get this function from official docs

| Access the functions and properties from the object. Retrieve the objects for all the collections by

| calling LrCatalog.getCollections().

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 04, 2022 Jul 04, 2022

Copy link to clipboard

Copied

LATEST

"It is strange because I get this function from official docs"

 

I just filed a bug report about that -- thanks for calling it out:

https://community.adobe.com/t5/lightroom-classic-bugs/minor-mistakes-in-sdk-documentation-referencin...

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines