Adding Smart Album
Hi everyone,
I'm totally new in scripting. I've been looking everywhere on this forum and on the internet for this info and I'm sorry if the answer has already been published somewhere but I've been struggling for days 'cause I just can't find out how to script smart albums in COP10.
I've been trying so far coding as for albums replacing the kind "smart album" instead of "album" without luck :
returns error "Error in Capture One 10Â : An error occurred while trying to make this collection." number -2710 from collection to class
And can somebody help me to figure out how to set the rules for smart albums ? Let's say I want a Smart Album with the preset "Color Tag is Red". Will the following line code work and be enough ?
Thank you very much for your help !
I'm totally new in scripting. I've been looking everywhere on this forum and on the internet for this info and I'm sorry if the answer has already been published somewhere but I've been struggling for days 'cause I just can't find out how to script smart albums in COP10.
I've been trying so far coding as for albums replacing the kind "smart album" instead of "album" without luck :
tell application "Capture One 10"
activate
tell document 1
set myNewSmartAlbum to make new collection with properties {name:"Test", kind:smart album}
end tell
end tell
returns error "Error in Capture One 10Â : An error occurred while trying to make this collection." number -2710 from collection to class
And can somebody help me to figure out how to set the rules for smart albums ? Let's say I want a Smart Album with the preset "Color Tag is Red". Will the following line code work and be enough ?
set color tag for myNewSmartAlbum to 1Thank you very much for your help !
0
-
I tried and got the same error. So I thought - perhaps its not possible to have a Smart Album without defining a rule.
I created a new Smart Album in the usual way with no rules, then used Applescript to read the rules:The results are:
log class of basicrules
log (get rules of collection 5)- (*text*)
(*<?xml version="1.0" encoding="UTF-8"?><MatchOperator Kind="AND"></MatchOperator>*)
Aha!! so the rules are a text string, and that is the text string for the default rules that do nothing. The following code segment works:There ya go.
set newrules to "<?xml version="1.0" encoding="UTF-8"?><MatchOperator Kind="AND"></MatchOperator>"
set theNewColl to make new collection with properties {kind:smart album, name:"Test 127", rules:newrules}0 -
Oh brilliant ! You're a genius Eric !!
So to get it work I just had to set my rules as a string as you mentioned and, for instance, to set the filter "Color Tag is Red" the following code works :
set newrules to "<?xml version="1.0" encoding="UTF-8"?><MatchOperator Kind="AND"><MatchOperator Kind="AND"><Condition Enabled="YES"><Key>IB_S_BASIC_URGENCY</Key><Operator>0</Operator><Criterion>1</Criterion></Condition></MatchOperator></MatchOperator>"
Thank you very much Eric !!!0 -
Just a bit of our code as additional examples (includes deleting collections):
tell application "Capture One 10"
set theDoc to current document
tell theDoc
browse to path sessionNamePathPosix & "/Capture"
delay 0.25
tell application "System Events" to key code 97
--------------------------------------------
--Make Initial Selects Smart Album (images that have star rating of 1 or more)
--------------------------------------------
set myRulesInitial to "<?xml version="1.0" encoding="UTF-8"?><MatchOperator Kind="AND"><MatchOperator Kind="AND"><Condition Enabled="YES"><Key>IB_I_BASIC_RATING</Key><Operator>2</Operator><Criterion>1</Criterion></Condition></MatchOperator></MatchOperator>"
make new collection with properties {kind:smart album, name:"Initial Selects", rules:myRulesInitial}
--------------------------------------------
--Make Final Selects Smart Album (images that have green label and rating of 1 or more)
--------------------------------------------
set myRulesFinal to "<?xml version="1.0" encoding="UTF-8"?><MatchOperator Kind="AND"><MatchOperator Kind="OR"><Condition Enabled="YES"><Key>IB_S_BASIC_URGENCY</Key><Operator>0</Operator><Criterion>4</Criterion></Condition><Condition Enabled="YES"><Key>IB_S_BASIC_URGENCY</Key><Operator>0</Operator><Criterion>5</Criterion></Condition></MatchOperator></MatchOperator>"
make new collection with properties {kind:smart album, name:"Final Selects", rules:myRulesFinal}
--------------------------------------------
--Delete 'Five Stars' and 'All Images' Smart Albums
--------------------------------------------
tell theDoc
if exists collection named "Five Stars" then
delete collection named "Five Stars"
end if
if exists collection named "All Images" then
delete collection named "All Images"
end if
end tell
end tell
end tell0
Post ist für Kommentare geschlossen.
Kommentare
3 Kommentare