Typically, plugins that wanted to apply settings to a photo would first create a plugin preset using LrApplication.addDevelopPresetForPlugin() and then apply that preset with photo:appyDevelopPreset(). This works very reliably, but it has one problem -- presets don't ignore any crop settings.
One way to work around that is, as you've found, to use LrDevelopController. But you've discovered that's slow, because the plugin needs to change the currently selected photo, which takes time. (By the way, you should probably put LrTasks.sleep(0.01) in the body of the while loop that's waiting, so that it doesn't consume too much CPU and starve the other LR tasks.)
Another thing to try is the undocumented photo:applyDevelopSettings(). I've only played with it a little bit, and I don't know if it's reliable or if it lets you set crop settings.
John, big thanks!!
photo:applyDevelopSettings() works perfectly and snapshot works like a charm!
This is the final code:
local syncParams = photo:getDevelopSettings()
photoImported:createDevelopSnapshot("Before syncing Dual ISO raw params", true)
Why this function isn't documented ? Which SDK requirement needed (Lr6?)
Many thanks for pointing to me to this undocumented function! I'll try to find more undocumented functions...
Fabulous, crop settings are synced too!
I'll try to find out why applyDevelopSettings isn't documented and will report back.
Thanks for mentioning applyDevelopSettings, John. I hadn't previously heard of its existence, but AFAICS it works like a dream. The inclusion of crop resolves a problem I've had ever since I wrote my Syncomatic plugin 6-7 years ago.
It may be new to Lr6 and I could not get it working in Lr4 or Lr5 where I get "attempt to call method 'applyDevelopSettings' (a nil value)"
I think it's a new function for LR6 and will not working for previous version. I apply this only when Lr version is at least 6.0
Many thanks for your help!
I'll try to find more undocumented functions...
Also see these threads for functions and methods that might not be documented: