Skip to main content

A handy little script to add a layer with inverted mask

Comments

2 comments

  • Sean Murphy
    Thanks for sharing Eric. That gets me thinking a bit on how our team uses their adjustment layers. Have you played with copying masks to different images? Is that easily done? We do that a lot but I haven't put much time into researching its scripting capabilities.

    On a side note, we don't often need to invert a mask on a different layer but do interact with layers programmatically. Here is a basic one we use for making an adjustment (shadow recovery in this case) to all images...plus I did my own naming of the layers since I wanted them more descriptive and didn't like the layer numbering. 😄


    tell application "Capture One 11"
    repeat with thisVariant in (get selected variants)
    set newLayerIndex to 1 + (count of every layer of thisVariant)
    set theNewLayer to make new layer of thisVariant with properties {name:"Shadow Recovery " & newLayerIndex}
    tell theNewLayer to fill mask
    end repeat
    end tell
    0
  • Eric Valk
    [quote="SeanMurp" wrote:
    Thanks for sharing Eric. That gets me thinking a bit on how our team uses their adjustment layers. Have you played with copying masks to different images? Is that easily done? We do that a lot but I haven't put much time into researching its scripting capabilities.

    I haven't tried it but I note that when I execute the the Applescript:
    get every layer of primary variant
    I get the responses:
    layer "Background" of variant 10 of collection 1 of collection 13 of document "Incoming"
    layer 2 of variant 10 of collection 1 of collection 13 of document "Incoming"

    Note that the reference to the layer also includes the variant, collection and document. Therefore this should work:

    tell application "Capture One 11"
    set sourceLayer to layer 2 of Variant 1
    set targetLayer to layer 3 of Variant 2
    copy mask sourceLayer to layer targetLayer
    end tell


    On a side note, we don't often need to invert a mask on a different layer but do interact with layers programmatically. Here is a basic one we use for making an adjustment (shadow recovery in this case) to all images...plus I did my own naming of the layers since I wanted them more descriptive and didn't like the layer numbering. 😄

    I would do the same.
    Note that in the fill mask command, your target is only defined by "theNewLayer" - the layer reference must include all the information about document, collection and variant.


    tell application "Capture One 11"
    repeat with thisVariant in (get selected variants)
    set newLayerIndex to 1 + (count of every layer of thisVariant)
    set theNewLayer to make new layer of thisVariant with properties {name:"Shadow Recovery " & newLayerIndex}
    tell theNewLayer to fill mask
    end repeat
    end tell


    I'bve started structuring my code along these lines - this eliminates an unnecessary variable, and the line continuation character ¬ still breaks the code into readable chunks

    tell application "Capture One 11"
    repeat with thisVariant in (get selected variants)
    set theNewLayer to make new layer of thisVariant with properties¬
    {name:"Shadow Recovery " & (get 1 + (count of every layer of thisVariant))}
    tell theNewLayer to fill mask
    end repeat
    end tell
    0

Please sign in to leave a comment.