Author Topic: Execute code/script on rating change?  (Read 1683 times)

ThisIsAnonymous

  • New Members
  • *
  • Posts: 10
Execute code/script on rating change?
« on: November 30, 2015, 04:02:18 PM »
Is it possible to execute some code or a script on rating change? I've been reading through the documentation and some of what I have read makes it sound like it would be possible to run code on changes to a file but I haven't been able to find an actual example or any further guidance. I specifically want to execute code when a rating is changed (for example, a rating is set to 5 stars or a file that was rated 3 stars is set to 1 star etc.) When those values are changed, I would like to execute my custom code.

I've been looking at the "Event Handling" portion of the help file and I assume I need to look at something in a "Database Script" but I have been lost from there. Any help or guidance would be greatly appreciated.

Thanks for the help.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: Execute code/script on rating change?
« Reply #1 on: November 30, 2015, 04:14:08 PM »
Why do you want to run a script when a rating changes?
What do you want to achive?

Event handling is complex, and I don't encourage users to use it. Frankly, I may drop support for event scripts in a future IMatch version.
It's too complex, may badly affect performance and it's a nuisance to maintain for the maybe 3 users world-wide who maybe use event scripts.
This is so special, I have only created it for very specific purposes.

In general, you can create a Database script and add an event handler for the Database_MetadataRatingChanged.
But whatever you do in that event handler may affect other parts of the database, cause performance problems, block critical database operations etc.



ThisIsAnonymous

  • New Members
  • *
  • Posts: 10
Re: Execute code/script on rating change?
« Reply #2 on: November 30, 2015, 04:36:24 PM »
Thank you for the reply.

I was hoping to track the number of times a file has been rated as a 5 star, 4 star etc.

To explain in detail, I will sometimes take a group of say 48 images from a shoot and compare them in groups of 8 (in the viewer). I will rate the 8 images in order of my preference from 5 - 1. This means for a group of 8, 5 images will have ratings and 3 images will not. I then will go back and review all of the images that did not receive ratings and I might delete them etc. (this is all part of my workflow). I generally continue this sort of "voting" system until I have reduced the images down to a number that I want to work with for my client. What happens is as I work through all of the images, I reset the ratings after each batch of images so that I'm "voting" for the best images again on each round. I was curious if I could somehow track the number of times I've given a specific image a 5, 4, 3 etc. through all of these "rounds"

I love all of the scripting/api options that are in place currently and even if rarely used, I would hate to see them go. However, I fully understand that it must be hard to keep all of those features if hardly anyone is using them.

Thanks again for the reply. As I read the help system, I noticed that it was indicating this sort of scripting could cause issues so that is why I asked.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: Execute code/script on rating change?
« Reply #3 on: November 30, 2015, 06:24:43 PM »
The Viewer has a promotion/demotion feature which allows you to work similar to a real light table.
Images you like best move to the front of the image queue in the Viewer. This is a great way to make up your mind about which files are keeper. Whether you do it alone or while sitting with your client.

When you leave the Viewer, you have the option to persist the image order in the custom profile for the folder / category.

Writing Database event scripts in order to track somewhere how often you have rated a file can be done in IMatch 5, but I doubt it will be worth the effort.

It would be easier to write a script which looks at a selection of files (e.g., all files in your current review round) and then sets/updates/sums in an Attribute according to the file rating before resetting the rating. This way you don't need to fiddle with event scripts and potential side effects. And when you create a Favorite for the script you can run it with a single mouse click or keyboard shortcut!

ThisIsAnonymous

  • New Members
  • *
  • Posts: 10
Re: Execute code/script on rating change?
« Reply #4 on: November 30, 2015, 07:12:47 PM »
Thank you for the suggestion. That actually sounds like a perfect idea and is much better than what I was thinking. I think I can write something like that as I have worked with attributes and scripting once before. My main goal was to persist the overall rating values and this would work well. I also have seen the examples for working with selected files so I'll start there.

Thanks.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: Execute code/script on rating change?
« Reply #5 on: November 30, 2015, 07:37:30 PM »
The Samples section in the script manager has samples for processing selected files, for modifying attributes etc. It should not be too hard to combine these into a script which doe what you need. The IMatch help also has lots of examples.