Script to Copy from Layer One to Layer Two

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

Script to Copy from Layer One to Layer Two

Postby NN635934285532082544UL » Thu Aug 02, 2018 12:18 am

Hello C1 Forum Geniuses!

Was hoping one of you Lords could help me write a script to perform a process that I do repeatedly every day - copy a mask from Layer 1, apply to Layer 2, and invert.

As a complete Wally, I'm at the stage of watching YouTube videos entitled 'AppleScript for n00bs' which isn't giving me much joy. Any assistance you could provide would be greatly appreciated,

Thanks,

Tim
NN635934285532082544UL
 
Posts: 3
Joined: Sun Mar 13, 2016 2:15 am

Re: Script to Copy from Layer One to Layer Two

Postby Eric Nepean » Thu Aug 02, 2018 3:33 am

Hi Tim
You should only spend so long watching those videos. The best way, and actually the only way, to learn Applescript is learn by doing.

Write a simple script. Then try to add something to it. It's broken. Google the command and the error message. Read the Applescript Dictionary. Open the Script Editor Log window. Check the Applescript events and replies. Fix it.

One of the key things is that when you are writing an Applescript, you should refer to the dictionary. Frequently.

Script Editor has a handy link to the Applescript Language guide. Here, click on the index, click on the first letter of a command, and then you will find all the references to a command. A normal human being can't possibly absorb the entire language reference, but individual sections pertaining to a command are very informative.

You have nothing to loose but your sanity :D

So:
  • Make a folder for your Applescripts
  • Open up script editor
  • Open up the log Window
  • Make a new empty script
  • Open Up the Applescript dictionary for CaptureOne.

Try this, and compare very line to the Dictionary
Code: Select all
 tell application "Capture One 11"
   set theVariantName to name of primary variant
   log theVariantName
   set theVariant to get primary variant
   tell theVariant
      set theLayerList to get every layer
      repeat with theLayer in theLayerList
         log {(get name of theLayer), (get kind of theLayer as text)}
      end repeat
      
      invert mask of layer "Layer 1"
      
      set theFirstLayer to get layer "Layer 1"
      set theSecondLayer to get layer "Layer 2"
      
      copy mask theFirstLayer to layer theSecondLayer
      invert mask of theSecondLayer
      
   end tell
end tell


Do come back and tell us how its going.
Last edited by Eric Nepean on Thu Aug 02, 2018 4:11 am, edited 1 time in total.
Cheers, Eric
[late 2015 iMac, 4GHz i7, 24GB RAM, external SSDs. GX8, E-M1, GX7, GM5, GM1 ....]
Eric Nepean
 
Posts: 402
Joined: Sat Oct 25, 2014 8:02 am

Re: Script to Copy from Layer One to Layer Two

Postby NN635934285532082544UL » Thu Aug 02, 2018 3:45 am

Good on you, Eric, that's awesome advice! Thank you - I'm going to have a crack at this now and get back to you.

t
NN635934285532082544UL
 
Posts: 3
Joined: Sun Mar 13, 2016 2:15 am

Re: Script to Copy from Layer One to Layer Two

Postby NN635934285532082544UL » Thu Aug 02, 2018 3:54 am

Oh man, that's beautiful! Thanks so much!

(But, one small note for anyone else trying to do this - I had to delete the first 'invert' line otherwise it inverts the first layer rather than the second)

Really appreciate that Eric.
NN635934285532082544UL
 
Posts: 3
Joined: Sun Mar 13, 2016 2:15 am

Re: Script to Copy from Layer One to Layer Two

Postby Eric Nepean » Thu Aug 02, 2018 4:18 am

NN635934285532082544UL wrote:Oh man, that's beautiful! Thanks so much!

(But, one small note for anyone else trying to do this - I had to delete the first 'invert' line otherwise it inverts the first layer rather than the second)

Really appreciate that Eric.


You're quite welcome Tim

I wrote it more as an example than as an application. I built it in my usual way, get one action working at a time.

You will probably want to fix it up a bit to choose the layers in more sensible way according to how you use layers, and perhaps you will want it to work on selected variants instead of the primary variant. And you probably don't want all those log messages in the end.
Cheers, Eric
[late 2015 iMac, 4GHz i7, 24GB RAM, external SSDs. GX8, E-M1, GX7, GM5, GM1 ....]
Eric Nepean
 
Posts: 402
Joined: Sat Oct 25, 2014 8:02 am


Return to Scripting



Who is online

Users browsing this forum: No registered users and 2 guests