Capture One's "kind" is broken in Applications

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

Capture One's "kind" is broken in Applications

Postby Eric Nepean » Mon Aug 06, 2018 4:33 pm

If you save your Applescript as an Application, you will find some unexpected behaviour if your script makes any decisions based on "kind" - "kind of layer", "kind of collection", "kind of document" "kind of watermark"

When AppleScript is executed as a script by Scripteditor , Capture One returns a string for all of these "kinds".

When AppleScript is saved and aexecuted as an application, by script editor or by Capture One, Capture One returns the chevron form for all of these "kinds". This is nothing like the string returned in the first case and can really bollix up the decision making in your script. It also makes displayed information including "kind" nonsensical.

My way of getting around this is to process the value of kind returned by Capture One with the following handler. I've updated it slightly to handle all the different kind values associated with Collections, Documents, Layers and Watermarks.

Code: Select all
on convertKind(kind_p)
   ## Release 11 of Capture One returns the chevron form of the property "kind" when AppleScript is run as an Application
   ## This script converts the chevron form into the expected string
   ## Code looks ugly but executes in under 0.25 msec
   
   set kind_s to kind_p as text
   if (get text 1 of kind_s) ≠ "«" then return kind_s -- Check if the first character is a Chevron. If not, return the same string
   
   ## minimum 6 characters for valid logic. Normally 19
   if 6 > length of kind_s then error  "convertKind received an unexpected Kind string: " & kind_s
   
   set code_start to (get length of kind_s) - 4
   set kind_code to get (text code_start thru (code_start + 3) of kind_s)
   set kind_type to get text 1 thru 2 of kind_code
   set fail_flag to false
   
   if kind_type = "CC" then ## Collection Kinds
      if kind_code = "CCpj" then
         set kind_res to "project"
      else if kind_code = "CCgp" then
         set kind_res to "group"
      else if kind_code = "CCal" then
         set kind_res to "album"
      else if kind_code = "CCsm" then
         set kind_res to "smart album"
      else if kind_code = "CCfv" then
         set kind_res to "favorite"
      else if kind_code = "CCff" then
         set kind_res to "catalog folder"
      else
         set fail_flag to true
      end if
      
   else if kind_type = "CL" then ## Layer Kinds
      if kind_code = "CLbg" then
         set kind_res to "background"
      else if kind_code = "CLnm" then
         set kind_res to "adjustment"
      else if kind_code = "CLcl" then
         set kind_res to "clone"
      else if kind_code = "CLhl" then
         set kind_res to "heal"
      else
         set fail_flag to true
      end if
      
   else if kind_type = "CR" then ## Watermark Kinds
      if kind_code = "CRWn" then
         set kind_res to "none"
      else if kind_code = "CRWt" then
         set kind_res to "textual"
      else if kind_code = "CRWi" then
         set kind_res to "imagery"
      else
         set fail_flag to true
      end if
      
   else if kind_type = "CO" then ## Document Kinds
      if kind_code = "COct" then
         set kind_res to "catalog"
      else if kind_code = "COsd" then
         set kind_res to "session"
      else
         set fail_flag to true
      end if
   else
      set fail_flag to true
   end if
   
   if fail_flag then error "convertKind received an unexpected Kind string: " & kind_s
   
   return kind_res
end convertKind
Cheers, Eric
[late 2015 iMac, 4GHz i7, 24GB RAM, external SSDs. GX8, E-M1, GX7, GM5, GM1 ....]
Eric Nepean
 
Posts: 367
Joined: Sat Oct 25, 2014 8:02 am

Re: Capture One 12 "kind" is broken in Applications

Postby Eric Nepean » Mon Dec 03, 2018 3:52 am

Note that this item is also broken in Capture One 12. I have raiseda ticket for it.
The workaround in my first post works.
Cheers, Eric
[late 2015 iMac, 4GHz i7, 24GB RAM, external SSDs. GX8, E-M1, GX7, GM5, GM1 ....]
Eric Nepean
 
Posts: 367
Joined: Sat Oct 25, 2014 8:02 am

Re: Capture One's "kind" is broken in Applications

Postby Eric Nepean » Tue Dec 04, 2018 3:06 pm

In response to the ticket that this is broken I got the usual message for AppleScript users.

Phase OneSupport wrote:Hi Eric,
We do not provide support with scripting
Kind regards,
Phase One Technical Support
Last edited by Eric Nepean on Tue Dec 04, 2018 9:03 pm, edited 1 time in total.
Cheers, Eric
[late 2015 iMac, 4GHz i7, 24GB RAM, external SSDs. GX8, E-M1, GX7, GM5, GM1 ....]
Eric Nepean
 
Posts: 367
Joined: Sat Oct 25, 2014 8:02 am

Re: Capture One's "kind" is broken in Applications

Postby Ernesto J. » Tue Dec 04, 2018 4:41 pm

Hi Eric,

This issue is more likely a framework problem, not unique to Capture One as I've seen similar things happen in e.g iTunes where the script runs fine from the editor (or indeed any other context), but chokes when invoked from the app.

Example:

tell application "iTunes"
display dialog "iTunes shuffle mode: " & (shuffle mode as text) buttons {"OK"}
end tell

When run from Script Editor will show “songs”, but when put into ~/Library/iTunes/Scripts and invoked from iTunes’ scripts menu, will display “”«constant ****kShS»”

Only thing I can think of you could try (I used it before to get around Excel's lack of app script folder) is maybe pipe the script through Automator and run the whole thing as a service. This snippet above returns "songs" when run in this way, but I admit to not testing this theory harder with Capture One.
Ernesto J.
 
Posts: 12
Joined: Mon Jul 11, 2016 4:28 pm

Re: Capture One's "kind" is broken in Applications

Postby Eric Nepean » Tue Dec 04, 2018 5:24 pm

Hi Ernesto
Thanks for the useful comment, you are the first to give some insight into what’s happening.

Rather than Automater a simple workaround is the handler I show in my first post, I’m using it today on Capture One 12 scripts. It covers all the possible values of Kind for different classes and the additional execution time seems insignificant.
Cheers, Eric
[late 2015 iMac, 4GHz i7, 24GB RAM, external SSDs. GX8, E-M1, GX7, GM5, GM1 ....]
Eric Nepean
 
Posts: 367
Joined: Sat Oct 25, 2014 8:02 am


Return to Scripting



Who is online

Users browsing this forum: No registered users and 1 guest