New Filled Adjustment Layer - Easiest Way to Do This?

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

New Filled Adjustment Layer - Easiest Way to Do This?

Postby SeanMurp » Wed Jun 06, 2018 5:27 pm

Is this the easiest way to create a new Filled Mask Adjustment Layer programmatically? (aside from hitting a keyboard shortcut)
Code: Select all
tell application "Capture One 11"
   set SelectedVariants to selected variants
   repeat with a from 1 to count of SelectedVariants
      set thisVariant to item a of SelectedVariants
               
      set LayerNames to name of every layer of item 1 of thisVariant
      set layerCount to count of LayerNames
               
      set newLayerName to make new layer of thisVariant with properties {name:"Filled Layer " & layerCount}
      set layerName to name of newLayerName
               
      tell layer layerName of thisVariant
         fill mask
      end tell
               
   end repeat
end tell

Obviously, there is some extra code in there so I could name the layer how I want and number the layers, but wanted to see if anyone had figured out some options quicker than: 1. Get the variant. 2. Create new layer. 3. Set variable to the newly created layer's name. 4. Fill that layer's mask. Just feels roundabout.
SeanMurp
 
Posts: 78
Joined: Wed Nov 02, 2016 4:30 am

Re: New Filled Adjustment Layer - Easiest Way to Do This?

Postby Eric Nepean » Thu Jun 07, 2018 12:26 pm

Hi Sean
Well you could certainly tighten up the code a bit.

If there was property of "layer" that included mask fill you could reduce the three "working" lines to two, but I don't see such a property.

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

or even better
Code: Select all
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:"Filled Layer " & newLayerIndex}
      tell theNewLayer to fill mask
   end repeat
end tell
Eric Nepean
 
Posts: 655
Joined: Sat Oct 25, 2014 8:02 am
Location: Ottawa

Re: New Filled Adjustment Layer - Easiest Way to Do This?

Postby SeanMurp » Thu Jun 07, 2018 2:46 pm

Thanks for the code cleanup Eric! Great to see how these things can be tightened up, but at least I was correct in understanding that there wasn't a simpler line of code like you mention about a property of layer for mask fill.
SeanMurp
 
Posts: 78
Joined: Wed Nov 02, 2016 4:30 am


Return to Scripting



Who is online

Users browsing this forum: No registered users and 1 guest