Capture One's "kind" is broken in Applications
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.
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.
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
0
-
Note that this item is also broken in Capture One 12. I have raiseda ticket for it.
The workaround in my first post works.0 -
In response to the ticket that this is broken I got the usual message for AppleScript users. [quote="Phase OneSupport" wrote:
Hi Eric,
We do not provide support with scripting
Kind regards,
Phase One Technical Support
0 -
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.0 -
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.0
Post ist für Kommentare geschlossen.
Kommentare
4 Kommentare