Zum Hauptinhalt gehen

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

Capture One Crashes While AppleScript Runs

Kommentare

13 Kommentare

  • Eric Nepean
    I would try replacing the refrence to "current doc" with an an absolute reference like document 1. "Current document" can change while the script is running.

    Perhaps a bit of code like this:

    ## This line of code would take care of it, but does not work: (suspect a bug in COP)
    ## set current_doc_abs to (get document whose name is current_doc_name) - inside a tell application "Capture One 10" section

    ## Therefore a less elegant approach is needed
    tell application "Capture One 10"
    set current_doc_name to (get name of current document) as string
    set current_doc_kind to (get kind of current document) as string
    if current_doc_kind ≠ "catalog" then error -- if you are using sessions, then change this accordingly
    set doc_list to get documents
    set found_doc to false
    repeat with this_doc in doc_list
    try
    set this_doc_name to (get name of this_doc) as string
    set this_doc_kind to (get kind of this_doc) as string
    if (this_doc_name = current_doc_name) and (this_doc_kind = current_doc_kind) then
    set current_doc_abs to this_doc
    set found_doc to true
    exit repeat
    end if
    end try
    end repeat
    if not found_doc then error "Document not found"
    end tell
    0
  • Eric Nepean
    Here is a much better piece of code.

    If you check the Script Editor log window under "events" or "replies" you should be able to see the last Apple event and the last reply before COP crashes. This will be very useful information.

    tell application "Capture One 10"
    set {current_doc_name, current_doc_kind} to (get {name, kind} of current document)
    set current_doc_abs_list to (get every document whose name is current_doc_name and kind is current_doc_kind)

    ##-- if you are using sessions, then change this next line accordingly
    set current_doc_kind to current_doc_kind as string

    set number_of_hits to count of current_doc_abs_list
    if number_of_hits = 0 then
    error "Could not find find " & current_doc_kind & current_doc_name
    else if number_of_hits > 1 then
    error "Found more than one " & current_doc_kind & " with the name " & current_doc_name
    else
    set current_doc_abs to item 1 of current_doc_abs_list
    end if
    end tell
    0
  • Sean Murphy
    Thanks a lot for the code Eric. The current document addition to the Capture One dictionary was a welcome addition in 10.1 (the prior alternative gave us lots of issues), but I'll give your code a try.
    0
  • Sean Murphy
    Well, I gave it a go and was very hopeful after the first running of the script. Unfortunately subsequent runs of the script results in the same crash/success pattern as I was experiencing earlier. The last few crashes being on this same line of the recipe creation:

    set output format of recipe "SHOPBOP JPEG 100% (sRGB)" of current_doc_abs to JPEG

    Links to full code below:
    -- this one contains Eric's suggested edits
    -- original version with 'current document' references
    0
  • Eric Nepean
    [quote="SeanMurp" wrote:
    Thanks a lot for the code Eric. The current document addition to the Capture One dictionary was a welcome addition in 10.1 (the prior alternative gave us lots of issues), but I'll give your code a try.

    I'm kind of shooting in the dark, since I don't know how your Applescript crashes, I would know more if I saw the Apple Events before the crash. But current document is a recent COP change, and so there is an elevated chance this is the cause.

    I do use current document and current collection and find them useful, but carefully, since in each case the object they reference may change while the Applescript is running.

    In my code snippet I quickly convert that current document reference to a something I call an absolute reference - absolute meaning that it is a reference that always points to the same document. Using an absolute reference makes the Applescript unaffected by changes in current document while it runs.

    current document references the document that receives the focus and the mouseclicks and keyclicks from COP and is its frontmost document. This may change at anytime COP decides that another document becomes the current document. The Applescript will not be notified that a change has occurred.

    In an Applescript with a few short commands, that is no problem as current document is unlikely to change while it runs. In a longer Applescript, it becomes a vulnerability as something like a user mouse click or some other internal COP process may cause current document to change while the script is running ... referring to a different documents with completely different contents - and then things will quickly go sideways.
    0
  • Eric Nepean
    [quote="SeanMurp" wrote:
    Well, I gave it a go and was very hopeful after the first running of the script. Unfortunately subsequent runs of the script results in the same crash/success pattern as I was experiencing earlier. The last few crashes being on this same line of the recipe creation:

    set output format of recipe "SHOPBOP JPEG 100% (sRGB)" of current_doc_abs to JPEG

    Links to full code below:
    -- this one contains Eric's suggested edits
    -- original version with 'current document' references


    Can we also get a listing of the Apple events or replies just before this happens?
    0
  • Eric Nepean
    [quote="SeanMurp" wrote:
    Well, I gave it a go and was very hopeful after the first running of the script. Unfortunately subsequent runs of the script results in the same crash/success pattern as I was experiencing earlier. The last few crashes being on this same line of the recipe creation:

    set output format of recipe "SHOPBOP JPEG 100% (sRGB)" of current_doc_abs to JPEG

    Links to full code below:
    -- this one contains Eric's suggested edits
    -- original version with 'current document' references


    I can't access the links. I get AccessDenied:
    Access DeniedAD3FD05116C0F71EvepB+1yPkAwNsHP2jNU8Phl52+yu4r8aaJCQVuQTWk8Bzmo5ft6IVuzVU8m2b703mjlEXN1Yefo=
    0
  • Sean Murphy
    Sorry, that access denied must be since those are apps and therefore a folder structure essentially. Here is a zip with both.

    Just figured out how to see Apple Events. 😊 Here is everything from the error, unfortunately, doesn't say a lot:

    tell current application
    do shell script "/bin/ls /Volumes"
    system info
    system info
    end tell
    tell application "System Events"
    get value of property list item "DT_Setup_Session" of property list item "currentVersionNumbers" of property list file "/Volumes/extensis/IP_Resources/_DT_Workflow_Applications/pLists_DO_NOT_DELETE/userApp_Version_Check.plist"
    exists property list item "seanmurp" of property list item "DT_Setup_Session" of property list item "IP" of property list file "/Volumes/extensis/IP_Resources/_DT_Workflow_Applications/pLists_DO_NOT_DELETE/userApp_Version_Check.plist"
    get value of property list item "seanmurp" of property list item "DT_Setup_Session" of property list item "IP" of property list file "/Volumes/extensis/IP_Resources/_DT_Workflow_Applications/pLists_DO_NOT_DELETE/userApp_Version_Check.plist"
    end tell
    tell current application
    do shell script "date +'%Y-%m-%d_%H-%M-%S'"
    end tell
    tell application "System Events"
    exists folder "/Volumes/WORKING/Sessions/DT_Session_2017-07-27_11-24-32"
    end tell
    tell application "Capture One 10"
    activate
    «data aevt646C65320000000061657674000001BC00000000000000000000013C0000000400000002000000000000000000000000636F7265636C6F730059499B00600000E05823000060000060572300006000004058230000600000805823000060000060582300006000008056230000600000E0572300006000000058230000600000C057230000600000E0522300006000006165767400010001637369676D61676E00000004000100007472616E6C6F6E6700000004000000006164647270736E200000000800000000001131137462736370736E20000000080000000000000000696E74656C6F6E670000000400000070726570716C6F6E6700000004000000007462736370736E2000000008000000000000000072656D6F6C6F6E67000000040000000066726F6D70736E2000000008000000000012F12F667265636C6F6E6700000004000000003B3B3B3B757372666C697374000000240000000200000000757478740000000C0073006100760069006E006766616C73000000002D2D2D2D6F626A20000000440000000400000000666F726D656E756D00000004696E647877616E747479706500000004646F637573656C646162736F00000004616C6C2066726F6D6E756C6C00000000»
    make new document with properties {name:"DT_Session_2017-07-27_11-24-32", path:"/Volumes/WORKING/Sessions/"}
    get name of current document
    get kind of current document
    get every document whose name = "DT_Session_2017-07-27_11-24-32.cosessiondb" and kind = session
    end tell
    tell application "System Events"
    exists folder "/Volumes/WORKING/Sessions/DT_Session_2017-07-27_11-24-32Transfer:"
    make new folder at folder "/Volumes/WORKING/Sessions/DT_Session_2017-07-27_11-24-32" with properties {name:"Transfer"}
    set frontmost of process "Capture One 10" to true
    click menu item "DT_Product_Workspace" of menu 1 of menu item "Workspace" of menu 1 of menu bar item "Window" of menu bar 1 of process "Capture One 10"
    set frontmost of process "Capture One 10" to true
    click menu item "Edit Keyboard Shortcuts…" of menu 1 of menu bar item "Capture One 10" of menu bar 1 of process "Capture One 10"
    set frontmost of process "Capture One 10" to true
    click pop up button 1 of window "Edit Keyboard Shortcuts" of process "Capture One 10"
    click menu item "Shopbop_Keyboard" of menu 1 of pop up button 1 of window "Edit Keyboard Shortcuts" of process "Capture One 10"
    click button "Close" of window "Edit Keyboard Shortcuts" of process "Capture One 10"
    end tell
    tell application "Capture One 10"
    get name of document "DT_Session_2017-07-27_11-24-32.cosessiondb"
    set capture name format of item 1 of every document to "Name/_/2 Digit Counter"
    set capture counter of document "DT_Session_2017-07-27_11-24-32.cosessiondb" to 0
    end tell
    tell application "System Events"
    set frontmost of process "Capture One 10" to true
    click menu item "Output" of menu 1 of menu item "Select Tool Tab" of menu 1 of menu bar item "View" of menu bar 1 of process "Capture One 10"
    end tell
    tell application "Capture One 10"
    exists recipe "A3 300dpi Print ready" of document "DT_Session_2017-07-27_11-24-32.cosessiondb"
    set enabled of recipe "A3 300dpi Print ready" of document "DT_Session_2017-07-27_11-24-32.cosessiondb" to false
    exists recipe "JPEG sRGB 1600px for web" of document "DT_Session_2017-07-27_11-24-32.cosessiondb"
    set enabled of recipe "JPEG sRGB 1600px for web" of document "DT_Session_2017-07-27_11-24-32.cosessiondb" to false
    exists recipe "JPEG sRGB QuickProof (preview size)" of document "DT_Session_2017-07-27_11-24-32.cosessiondb"
    set enabled of recipe "JPEG sRGB QuickProof (preview size)" of document "DT_Session_2017-07-27_11-24-32.cosessiondb" to false
    exists recipe "JPEG sRGB" of document "DT_Session_2017-07-27_11-24-32.cosessiondb"
    set enabled of recipe "JPEG sRGB" of document "DT_Session_2017-07-27_11-24-32.cosessiondb" to false
    exists recipe "TIFF Adobe RGB (1998) (8bit)" of document "DT_Session_2017-07-27_11-24-32.cosessiondb"
    set enabled of recipe "TIFF Adobe RGB (1998) (8bit)" of document "DT_Session_2017-07-27_11-24-32.cosessiondb" to false
    exists recipe "SHOPBOP JPEG 100% (sRGB)" of document "DT_Session_2017-07-27_11-24-32.cosessiondb"
    set enabled of recipe "SHOPBOP JPEG 100% (sRGB)" of document "DT_Session_2017-07-27_11-24-32.cosessiondb" to true
    set output format of recipe "SHOPBOP JPEG 100% (sRGB)" of document "DT_Session_2017-07-27_11-24-32.cosessiondb" to JPEG

    Result:
    error "Capture One 10 got an error: Connection is invalid." number -609

    0
  • Eric Nepean
    I go the zip, thanks.

    One thing I see from the events was that a new recipe was not created - that event did not occur. I think your crash may be occurring when you try to update a recipe which already existed at the start of the Applescript. Why? not sure.

    One thing that comes to mind is that the crashes seem to be intermittant - some times they occur, sometimes not. Could make vs existing be the differentiator between crash and not crash?

    Try changing the code as below to further differentiate the cause of the crash.

    You have

    if not (exists recipe "SHOPBOP JPEG 100% (sRGB)" of current document) then make new recipe of current document with properties {name:"SHOPBOP JPEG 100% (sRGB)"}
    --Basic tab
    set enabled of recipe "SHOPBOP JPEG 100% (sRGB)" of current document to true
    --sometimes crashes at this point
    set output format of recipe "SHOPBOP JPEG 100% (sRGB)" of current document to JPEG
    -- more recipe settings


    Try this

    if not (exists recipe "SHOPBOP JPEG 100% (sRGB)" of current document) then
    make new recipe of current document with properties {name:"SHOPBOP JPEG 100% (sRGB)"}
    --Basic tab
    set enabled of recipe "SHOPBOP JPEG 100% (sRGB)" of current document to true
    set output format of recipe "SHOPBOP JPEG 100% (sRGB)" of current document to JPEG
    -- more recipe settings
    else
    --Basic tab
    set enabled of recipe "SHOPBOP JPEG 100% (sRGB)" of current document to true
    set output format of recipe "SHOPBOP JPEG 100% (sRGB)" of current document to JPEG
    -- more recipe settings
    end if
    0
  • Eric Nepean
    Hi Sean

    I replicate your problem.

    Trying to set the Output format to JPEG in an already existing recipe in a session causes COP to crash. The same works OK in a catalog.

    I have raised case 257864 with support, you should do the same.


    tell application "Capture One 10"
    set {current_doc_name, current_doc_kind} to (get {name, kind} of current document)
    set current_doc_abs_list to (get every document whose name is current_doc_name and kind is current_doc_kind)

    set current_doc_kind to current_doc_kind as string
    --if current_doc_kind ≠ "catalog" then error

    set number_of_hits to count of current_doc_abs_list
    if number_of_hits = 0 then
    error "Could not find find " & current_doc_kind & current_doc_name
    else if number_of_hits > 1 then
    error "Found more than one " & current_doc_kind & " with the name " & current_doc_name
    else
    set current_doc_abs to item 1 of current_doc_abs_list
    end if

    tell current_doc_abs
    get name of every recipe

    get output format of recipe "JPEG sRGB"

    log {class of result}
    set output format of recipe "JPEG sRGB" to JPEG

    end tell
    end tell
    0
  • Sean Murphy
    Thanks for helping Eric. I had already created a support ticket (257696) but will put a reference to this forum thread and your ticket.

    I might see about moving away from creating the recipe each time, moving it behind the scenes to the user's recipe folder and just asking the team to manually choose that recipe when working. If taking this bit of code out prevents the repetitive crashes I'm pretty sure that will be the preferred user experience.

    Thanks again,
    Sean
    0
  • Eric Nepean
    [quote="SeanMurp" wrote:
    Thanks for helping Eric. I had already created a support ticket (257696) but will put a reference to this forum thread and your ticket.

    I might see about moving away from creating the recipe each time, moving it behind the scenes to the user's recipe folder and just asking the team to manually choose that recipe when working. If taking this bit of code out prevents the repetitive crashes I'm pretty sure that will be the preferred user experience.

    Thanks again,
    Sean


    I got a reply to my ticket that "Phase One does not offer any official support for scripting"
    0
  • Sean Murphy
    I got a response that is more helpful:

    Diggin ginto the code, it is reproducible on occasion- as you said, never the first time and always right when specifying an existing recipe format to JPEG (which makes sense, considering your recipe is created the first go-round without issue). I also can't get the crash to happen when changing the property to TIFF, which is a bit telling as well. However, if I isolate that recipe check/creation section and run it alone.

    The crash doesn't occur. Is it the same in your environment?

    As you'd mentioned in the forum, it may be better to create/copy the recipe xml outside of the Capture One tell. Or, it might not be the prettiest code to simply trash the existing Shop Bop recipe, and create the recipe anew every time, rather than check if it exists already.

    Let me know what you find, this is an interesting case indeed.


    I ended up moving our pre-made recipe into the user's library and now just disable the default recipes and enable our custom recipe. Seems to be working much better and without crashes.
    0

Post ist für Kommentare geschlossen.