Skip to main content

Script to toggle black & white for selected variants

Comments

10 comments

  • Mike Conley

    It occurs to me that I need to modify this script so that it can tell whether the current view is the Viewer or the Browser, because as it stands, it toggles the B&W setting on all variants selected in the Browser, ignoring the current selection in the Viewer. So, a bit more work, but probably not too difficult. I may post the updated version here once I get it going if anyone is interested.

    0
  • www.shootmachine.co

    What is selected is always defined via the browser - I don't really follow the comment about the viewer, but I don't think you have any way of accessing what is currently viewed in the viewer via scripting - beyond assuming - e.g setting 1 up view/ and then the primary variant (again what is primary variant is defined in browser).

    2
  • yann gauthier

    That's great work man, thanks a lot for sharing this!

    1
  • Paula Dieterman

    Hi there

    I just started diving into scripting for Capture One. Because I just cannot get myself to work with Apple Script I'll be working with JXA, and will share some code, mainly just for the fun of it, maybe it will interest some of you. The equivalent of the code above looks something like this in JXA:

    app = Application("Capture One 22");
    app.includeStandardAdditions = true;
    vs = app.documents.images[0].variants.whose({_match: [ObjectSpecifier().selected, true]});
    for (let v of vs()[0] ){v.adjustments.blackAndWhite = v.adjustments.blackAndWhite() == true ? "false" : "true";}

    You gotta admit it's a little more compact. Performance wise there is nothing meaningful I can say about it, I tested it with an image with a hand full of variants so I couldn't see a difference with the AS version. 

    As for the issue with the multiple undo/redo actions: I haven't found a way yet to sail around that one. Maybe I'll find something, I'll let you know.

    Best wishes

    Paula

     

     

     

     

     

    1
  • Mike Conley

    www.shootmachine.co: Yes, you're right. I was getting a bit confused with the highlighting of the current variant in the Viewer, but that's not the same as a selection, really. Anyway, it works as is. Cheers!

    0
  • www.shootmachine.co

    but that's not the same as a selection

    Mike Conley how's that?

    0
  • Paula Dieterman

    I get the confusion now. What is selected is determined in the browser, but if you select multiple variants you can toggle through them in the viewer by clicking or by using the arrow keys. Technically they are all still selected though, but the highlighting may suggest otherwise. There is no way of retrieving which variant is 'selected' in the viewer, as far as I can tell.

    1
  • Eric Valk

    Paula Dieterman Where do you find the language reference for JXA, especially the CaptureOne JXA terminology?

    0
  • Paula Dieterman

    Eric Valk Of course you won't find any on the C1 website. References, handbooks etc are quite sparse and/or old, like the official Apple release notes, but there are some good starting points, like this one: https://gist.github.com/JMichaelTX/d29adaa18088572ce6d4.

    There are some good examples to be found here: https://jxa-examples.akjems.com/.

    I found this one very helpful: https://bru6.de/jxa/, it will definitely help you avoiding some pitfalls when starting with jxa. If you work with Apple's script editor you can select the Capture One library and choose "JavaScript', just as you would with AppleScript. The terminology is the same and when you have found your way around the cliffs in JXA, it will feel familiar.

     

     

    0
  • Paula Dieterman

    Walter Rowe I assume you mean the variant that is picked? That is nothing more than the variant that is promoted to the top spot of the variant list. You can look for a variant that is picked in a script, but that doesn't necessarily mean it is selected by the user. Whatever variant is selected in the viewer will be highlighted and synchronised with the browser. 

    0

Please sign in to leave a comment.