Skip to main content
Known Participant
October 12, 2023
Question

Way to get presets path via SDK

  • October 12, 2023
  • 1 reply
  • 209 views

Hi. Fixing an old plugin that saved its naming templates in the old standard path. It breaks if you've got the option to store presets with catalog selected. Anyone know if there's a way to get the path that LR is using for preset storage via the API?

Tks.

This topic has been closed for replies.

1 reply

johnrellis
Legend
October 12, 2023

The API doesn't provide any way to determine that. I thought perhaps that LrApplication.addDevelopPresetForPlugin() could be used, but there are two problems:

 

- That method always creates the preset in a subfolder of the "appData" folder, regardless of the setting of Store Presets With This Catalog.

 

- Invoking any method on the returned LrPreset object, e.g. preset:getFile(), results in "assertion failed".

 

So I think your only option is to read the LR preferences file with LrFileUtils.readFile() and extract the current setting of Store Presets With This Catalog from it.  The setting stored in the preferences file may be stale by 60 seconds on Windows, perhaps the same on Mac, depending on Lr and Mac OS's policy for writing the cached preferences back to disk.  But in practice, it's probably very rare that the user has just changed Store Presets With This Catalog before running your plugin, so this hack would probably work well.

sebmsgAuthor
Known Participant
October 12, 2023

That's a great idea.  Thanks!