Skip to main content

⚠️ Please note that this topic or post has been archived. The information contained here may no longer be accurate or up-to-date. ⚠️

Why does one work and the other doesn't?

Comments

5 comments

  • Eric Valk

    In the case of the first one liner (setting the color tag) we are assigning the same numerical value to the property of a list of variants, each variant's property legitimately gets the same value.

    In the case of setting the current layer of a list of variants, each layer of each variant is an object,; that object is identified like one of

    • layer Background" of variant id "1089" of collection  id "203" of collection ....
    • layer 2 of variant id "1089" of collection  id "203" of collection ....

    Assigning the current layer of variant 1089 to be some layer of variant 1084 is problematic and some SW developer is going to handle that with an error message.

    So when we (try) to do this as a one liner the length of the list of current layers has to match the length of the list of layers that are assigned to it, and the object ID's have to match item for item.

    I tried this prototype code below, which meets these conditions. (its not a one liner yet, but could be massaged into one). It doesn't throw an error, but it also doesn't change the current layer. Selected variants whose current layers are not the background layer don't change their current layers.

    For now, I think the only solution is your code using a repeat loop.

    I think this is a bug, developers probably didn't think of verifying this.

    if true then
        tell application "Capture One 23" to tell (every variant whose selected is true)
            set C to get current layer
            set A to get first layer
            set B to get second layer
            set C to A
        end tell
    end if

     

     

    0
  • Walter Rowe
    Moderator
    Top Commenter

    Thank you Eric for looking at this and for your detailed explanation.

    0
  • Jim Schaub

    Since first layer is a list try this:

    tell application "Capture One" to tell (every variant whose selected is true) to set current layer to item 1 of (first layer)

    0
  • Walter Rowe
    Moderator
    Top Commenter

    Eric Valk

    It makes sense why this code below doesn't throw an error. You have only "read" the properties. You have not tried to set any of them.

    if true then
        tell application "Capture One 23" to tell (every variant whose selected is true)
            set C to get current layer
            set A to get first layer
            set B to get second layer
            set C to A
        end tell
    end if
    0
  • Walter Rowe
    Moderator
    Top Commenter

    Jim Schaub

    tell application "Capture One" to tell (every variant whose selected is trueto set current layer to item 1 of (first layer)

    That worked! One issue is that it fails when NO variants are selected. In my script it addresses this by setting the variant list to all variants if no variants are selected. One could alternatively simply do nothing if no variants are selected.

    -- select image (backgreound) layer of selected variants
    use AppleScript version "2.4"
    use scripting additions

    tell application "Capture One"
        set selVarList to get selected variants
        if count of selVarList is 0 then set selVarList to all variants
        repeat with thisVariant in selVarList
            tell thisVariant to set current layer to first layer
        end repeat
    end tell
    0

Post is closed for comments.