Create new session using template?
Anyone know if you can programmatically create a new session using a pre-made session template? There doesn't seem to be anything in the Capture One AppleScript dictionary that relates to this. It is not necessary for our workflow but would be a nice to have.
In case anyone wants/needs it, our current create new session code (session name and session path are pre-defined in a separate part of our script):
In case anyone wants/needs it, our current create new session code (session name and session path are pre-defined in a separate part of our script):
tell application "Capture One 10"
activate
close every document without saving
set newDoc to make new document with properties {name:sessionName, path:sessionFolderPath}
end tell
0
-
Hi, Sean.
I lifted your code and made this:set sessionFolderPath to "Macintosh HD:Users:Br415a8:Desktop"
set sessionName to "Bobo"
tell application "Capture One 11"
activate
close every document without saving
set newDoc to make new document with properties {name:sessionName, path:sessionFolderPath}
end tell
But I get this error. Not sure what to do?
error "Capture One 11 got an error: Cannot set because there is no file at this location." number -430 -
Hi Bret,
Should be a really easy fix to get it working. Use the POSIX path for the sessionFolderPath instead of the HFS path. So in this case it should be:
set sessionFolderPath to "/Users/Br415a8/Desktop/"
set sessionName to "Bobo"
tell application "Capture One 11"
activate
close every document without saving
set newDoc to make new document with properties {name:sessionName, path:sessionFolderPath}
end tell0 -
We have also added in a System Events check to make sure the folder doesn't already exist. If it does exist then the user is prompted with a dialog asking if they want to replace or name differently. 0 -
You can now do this in 11.1 using pre-saved templates. 0 -
Great! Just updated and can't wait to give it a try. 0 -
I'm trying a similar thing here, but I can't get it to work.
I created a template called shoot.cosessiontemplate and saved it in the bundle under resources folder.
I defined sessionLoc, sessionName and then I try to use following code to create the session, but I keep getting errors.
Tried using POSIX path as well but I still get errors saying can't find template..
Any suggestions?
CO v12
error message: "Capture One 12 got an error: No template of this name exists for this kind of document." number -2710 from document to class
set templateFile to path to resource "shoot.cosessiontemplate"
tell application "Capture One 12"
make new document with properties {path:sessionLoc, name:sessionName, template:templateFile}
end tell
full code I have so far:
set sessionLoc to choose folder
set {year:yy, month:mm, day:dd} to (current date)
if mm as number < 10 then
if dd < 10 then
set Today to (yy - 2000 & 0 & (mm as number) & 0 & dd) as string
else
set Today to (yy - 2000 & 0 & (mm as number) & dd) as string
end if
else
if dd < 10 then
set Today to (yy - 2000 & (mm as number) & 0 & dd) as string
else
set Today to (yy - 2000 & (mm as number) & dd) as string
end if
end if
set Today to the text returned of (display dialog "Date" default answer Today)
set shootName to the text returned of (display dialog "Shoot" default answer "")
set folderPrefix to the text returned of (display dialog "Shot folders prefix" default answer "")
set sessionName to Today & "_" & shootName as string
display alert "Session '" & sessionName & "' will be created" message POSIX path of sessionLoc
set templateFile to path to resource "shoot.cosessiontemplate"
tell application "Capture One 12"
make new document with properties {path:sessionLoc, name:sessionName, template:(POSIX path of templateFile as text)}
end tell0 -
I think yout problem may be with the us of "path to resource".
I see a note here
that says this doesn't work with Script Editor.
I also wonder which application's resource folder you have put the template in, is it Capture One or the Script Bundle?
If in the Script, the Script has to be a Script Bundle, that is a .scptd file, not a .scpt file.
If in Capture One (I wouldn't recommend this), you need to include the "In Bundle ... " part of the command
I recommend you open the Applescript Dictionary for Standard Additons, and search for "Path To"
As a debugging move, perhaps create a file "Resources" on your desktop, refer to that, and see if your script will work.
As you develop your Script you might consider alternatives for storing your template, for example
~/Library/Preferences/CaptureOneTemplates
get (path to preferences folder as string) & "CaptureOneTemplates"0 -
Thank you for the tips Eric,
I am working in a script bundle and I have the template file directly under the resources folder.
My main goal is to have a standalone app that I can share between different computers, so that it sets up a session with my desired session template. Ultimately I would also like it to load certain process recipes that i will include in the resources folder.0 -
I tried different variations, but no way I could get "path to resource" to work on a script bundle that Script Editor is running.
What I could get to work is this:
I copied a file I happened to have on my desk top inside the resources folder of a test Script (bundle).
I noticed that a file "description.rtfd" was already present.
The Test script is this:
set theAPath to (path to resource "description.rtfd") as string -- this works
set theScriptPath to get path to me
set theResourcePath_S to (theScriptPath as text) & "Contents:Resources:" & "ericscomputer.txt"
get alias theResourcePath_S -- this works
set theEPath to (path to resource "ericscomputer.txt") as string -- this doesn't work0 -
I found the solution to my problem!
The document 'template' property expects a text input (the template filename, without file extension) and NOT a file or filepath, it then looks for that template in the default templates folder for Capture One.
So what i do now,
I first tell finder to copy my template file from the bundle resources folder to ~/Library/Application Support/Capture One/Templates
And then call on the template when creating the new document.
I also learned that specifying a template when creating a new document only works if you specify the document kind as a session.
set theTemplateFile to (path to resource "script-template.cosessiontemplate")
tell application "Finder"
copy file theTemplateFile to folder ((path to home folder as string) & "â©Libraryâ©:Application Supportâ©:Capture One:Templatesâ©")
end tell
tell application "Capture One 12"
make new document with properties {kind:session, path:sessionLoc, name:sessionName, template:"script-template"}
end tell0 -
[quote="NNN635591107104249611" wrote:
I found the solution to my problem!
The document 'template' property expects a text input (the template filename, without file extension) and NOT a file or filepath, it then looks for that template in the default templates folder for Capture One.
So what i do now,
I first tell finder to copy my template file from the bundle resources folder to ~/Library/Application Support/Capture One/Templates
And then call on the template when creating the new document.
I also learned that specifying a template when creating a new document only works if you specify the document kind as a session.
set theTemplateFile to (path to resource "script-template.cosessiontemplate")
tell application "Finder"
copy file theTemplateFile to folder ((path to home folder as string) & "â©Libraryâ©:Application Supportâ©:Capture One:Templatesâ©")
end tell
tell application "Capture One 12"
make new document with properties {kind:session, path:sessionLoc, name:sessionName, template:"script-template"}
end tell
Good work and thanks for sharing what you have learned!!
Do you run this script from Script Editor or from Capture One? And which version of OSX are you using?0 -
Good work and thanks for sharing what you have learned!!
Do you run this script from Script Editor or from Capture One? And which version of OSX are you using?
I've been running it from the script editor up until now. I also plan on letting the script run first and letting it open and set up the capture one session.
I'm on MacOS Mojave 10.14.2
Capture One v120
Post is closed for comments.
Comments
12 comments