Copy and Apply adjustments

Discussion regarding all scripting related questions
Please DO NOT post to this thread anything that is not directly related to scripting of Capture One.

Copy and Apply adjustments

Postby PriamThomas » Tue Feb 25, 2020 3:30 pm

Hi there! I'm trying to apply adjustments to the last variant in a folder in C1 using a script. Currently I'm able to apply a user style, but I cant find any examples of how to apply settings from the Adjustments Clipboard. Ideally I'd like to be able to copy settings to clipboard from an image with a script, and then apply them to the last variant with another like the one below:

Code: Select all
tell application "Capture One 20"
tell current document
   set theVariant to the last variant
   apply adjustments to theVariant

end tell
end tell


The dictionary shows "copy adjustments" and "apply adjustments" as options, but "apply adjustments to theVariant" doesn't work, and I have no idea how to figure out the proper syntax. Can someone point me in the right direction?

Thanks!
Priam
PriamThomas
 
Posts: 1
Joined: Wed Jul 13, 2016 5:05 pm

Re: Copy and Apply adjustments

Postby Eric Nepean » Thu Feb 27, 2020 4:34 am

Apple's Script Editor has such a lousy debugging interface. Script debugger gives so much more information.

This works, the extra word "to" is the problem:
Code: Select all
tell application "Capture One 20"
   tell current document
      set theVariant to the last variant
      apply adjustments theVariant
   end tell
end tell

What you are really working with is the variants that Capture One is showing, so tell current document isn't needed:
Code: Select all
tell application "Capture One 20"
   set theVariant to the last variant
   apply adjustments theVariant
end tell

You could actually just write it like this
Code: Select all
tell application "Capture One 12" to apply adjustments (last variant)

It isn't immediately obvious that this should work, but it does, and is easier to read:
Code: Select all
tell application "Capture One 12" to tell last variant to apply adjustments

When Applescript sees this construct: tell zzz to yyy it interprets this as: execute the verb yyy onto the object zzz

In the above line
tell application "Capture One 12" --> set the default target of following commands to "Capture One 12"
to tell last variant --> set the default target of following commands to last variant (of Capture One 12)
to apply adjustments --> apply adjustments, since the target isn't specified after the command, use the default target

One thing that is really difficult to learn in Applescript is the object model e.g. Application "Capture One" contains variants, and variants are also contained by collections which are contained by documents which are contined by the application.

Script Debugger has a very useful Object Explorer which shows the object hierarchy, and what's in it for the running application.
Eric Nepean
 
Posts: 678
Joined: Sat Oct 25, 2014 8:02 am
Location: Ottawa


Return to Scripting



Who is online

Users browsing this forum: No registered users and 1 guest