2 Replies Latest reply on Jul 21, 2015 4:32 PM by johnrellis

    lua Lightroom 6 script lrcatalog calls failing "assertion failed"

    Iain Malcolm Level 1

      I'm trying to get the info about current folders etc in a lua script but it just fails "assertion failed" This happens for getFolders() and getActiveSourceas(). type() works OK and returns LrCatalog.

       

      Even with a sleep call added it fails - although Lightroom has been running for several minutes.

       

      local LrFunctionContext = import 'LrFunctionContext'

      local LrApplication = import 'LrApplication'

      local LrTasks = import 'LrTasks'

      local LrBinding = import 'LrBinding'

      local LrDialogs = import 'LrDialogs'

      local LrLogger = import 'LrLogger'

      local LrView = import 'LrView'

       

      -- Create the logger and enable the log print function.

       

      local myLogger = LrLogger( 'libraryLogger' )

      myLogger:enable( "logfile" ) -- Pass either a string or a table of actions.

       

      -- Write trace information to the logger.

      local function outputToLog( message )

        myLogger:trace( message )

      end

       

      local function showCustomDialog()

       

        outputToLog("two")

      -- LrTasks.sleep(3)

        LrFunctionContext.callWithContext( "showCustomDialog", function( context )

        outputToLog("three")

        local actCat = LrApplication.activeCatalog()

       

       

        outputToLog(actCat.type())

       

        local trying = actCat.getFolders()

       

      -- local photosets = actCat.getActiveSources()

       

        local f = LrView.osFactory()

       

           -- Create a bindable table.  Whenever a field in this table changes

           -- then notifications will be sent.

        local props = LrBinding.makePropertyTable( context )

        props.isChecked = false

       

        props.checkboxstate = "bimble"

       

        outputToLog("four")

           -- Create the contents for the dialog.

            local c = f:row {

       

           -- Bind the table to the view.  This enables controls to be bound

           -- to the named field of the 'props' table.

          

        bind_to_object = props,

           -- Add a checkbox and an edit_field.

          

        f:checkbox {

           title = "Enable",

           value = LrView.bind( "isChecked" ),

            },

       

        f:edit_field {

        value = "Some Text",

        enabled = LrView.bind( "isChecked" )

        },

        f:static_text{

        title = LrView.bind( "checkboxstate" )

        },

       

        f:checkbox {

        title = "Other Enable",

        value = LrView.bind( "checkboxstate" ),

        checked_value = "yes",

        unchecked_value = "no"

        }

        }

       

       

            LrDialogs.presentModalDialog {

           title = "Custom Dialog",

           contents = c

        }

       

       

        end) -- end main function

       

      end

       

       

      -- Now display the dialogs.

       

       

      LrTasks.startAsyncTask(function()

          showCustomDialog()

      end)