3 Replies Latest reply on Jun 11, 2009 2:00 PM by DawMatt

    Problem with writing metatdata

    Gene McCullagh Most Valuable Participant (Moderator)

      I am no Lua coder but am muddling my way through. Here's my problem:

       

      I have a dialog set up which allows a user to select from a dropdown any of the currently selected images. The remainder of the dialog will fill with the chosen image's metadata. The user can make changes. When done they press OK and the changes are written back to the catalog.

       

      I must be missing something somewhere because whatever image is up when the user presses OK is the source for the metadata. So, all images selected get that image's metadata instead of what was in the fields for each image.

       

      Here's the code used to write back the data.

       

       

      activeCatalog:withWriteAccessDo( "Plugin Title", function()

      local photosToUpdate = activeCatalog.targetPhotos

           for i, photo in ipairs(photosToUpdate) do

       

                photo:setRawMetadata('title',propertyTable.imageTitle)

                photo:setRawMetadata('caption', propertyTable.imageDescription)

                photo:setPropertyForPlugin(_PLUGIN,'relProperty', propertyTable.propertyReleaseStatus)

                photo:setPropertyForPlugin(_PLUGIN,'relPropertyFile',  propertyTable.propertyReleaseFile)

       

           end

      end )

       

      Any direction would be greatly appreciated! Thanks!
        • 1. Re: Problem with writing metatdata
          Mark J M Wilson Level 1

          Your code looks OK, so it might be in the dialog.

           

          How do you populate the fields when you select the photo from the drop-down?  I am wondering if there is a missing bind_to_object.

          1 person found this helpful
          • 2. Re: Problem with writing metatdata
            Gene McCullagh Most Valuable Participant (Moderator)

            Thanks Mark!

             

            No, I have the bind_to_object in place. Since the write back code looks OK I am thinking that perhaps having the write back in the same function as the dialog box might be the problem. I could stick it in a separate function to be called after the dialog is closed but I am not sure how to pass the propertyTable on to the next function.  As I said I'm no Lua coder.

             

            Do you think that would work? How do I pass the propertyTable from one function to the other?

            • 3. Re: Problem with writing metatdata
              DawMatt Level 3

              Gene McCullagh wrote:

               

              No, I have the bind_to_object in place. Since the write back code looks OK I am thinking that perhaps having the write back in the same function as the dialog box might be the problem. I could stick it in a separate function to be called after the dialog is closed but I am not sure how to pass the propertyTable on to the next function.  As I said I'm no Lua coder.

               

              Do you think that would work? How do I pass the propertyTable from one function to the other?

              A property table is just another variable.  You can return it and pass it into a function.  Or declare it in a higher/wider scope and treat it as a global variable.  This plugin of mine is open source and uses property tables to exchange data between a dialog and other functions.  Don't know whether it will resolve your problem but you might as well give it a shot.

               

              Matt