A handy little script to add a layer with inverted mask
This Script copies adds a new layer, then copies the mask from the previous topmost adjustment layer to the new layer and inverts it. It handles without error the cases when no variant is selected, the selected variant has no adjustment layer, and the topmost layer is not an adjustment layer.
Thanks to NN245802UL for the idea,
tell application "Capture One 11" to tell (get primary variant)
if (1 = (get count of it)) then
if (0 < (get count of (get every layer whose kind is adjustment))) then
set theFirstLayer to get last layer whose kind is adjustment
set theSecondLayer to make new layer at end
copy mask theFirstLayer to layer theSecondLayer
invert mask of theSecondLayer
else
make new layer at end
end if
end if
end tell
Thanks to NN245802UL for the idea,
0
-
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 tell0 -
[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 tell0
Please sign in to leave a comment.
Comments
2 comments