getting size of a variant

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

getting size of a variant

Postby NN635523068592468562UL » Thu Jun 22, 2017 10:38 am

Hi,
I am looking for a way to find each variants of a specific size.

I try to get the size or the crop size of a variants and always obtain an error.
Here is the code :
Code: Select all
global size_settings, my_variants

tell application "Capture One 10"
   set my_variants to selected variants
   set size_settings to (get crop size of my_variants)
end tell

return size_settings


May someone tell me where is the issue?
Thanks very much,
Philippe
NN635523068592468562UL
 
Posts: 14
Joined: Sun Nov 23, 2014 3:34 am

Re: getting size of a variant

Postby Eric Nepean » Sat Jun 24, 2017 7:31 am

Hi Philippe
Here is an interesting script.

This works:( If you tell the document)
get crop size of variants

whereas this does not:
set my_variants to get variants
get crop size of my_variants

and this works
get crop size of item 1 my_variants

Code: Select all
tell application "Capture One 10"
   set app_sel_variants to selected variants
   log app_sel_variants
   count of app_sel_variants
   
   crop size of item 1 of app_sel_variants
   try
      crop size of app_sel_variants
   on error errmess
      log "Error Message1--> " & errmess
   end try
   
   try
      crop size of selected variants
   on error errmess
      log "Error Message2--> " & errmess
   end try
   
   documents
   set Appl_Curr_Doc to current document
   
   tell current document
      name of collection 1
      name of current collection
      count of images
      count of variants
      set doc_variants to variants
      
      crop size of variants
      crop size of item 1 of doc_variants
      try
         crop size of doc_variants
      on error errmess
         log "Error Message3--> " & errmess
      end try
      
      
      tell current collection
         count of images
         count of variants
         crop size of variants
      end tell
   end tell
end tell
Cheers
Eric
(OSX 10.12, iMac and MacBook Air, Panasonic GX7,GM5,G5, Olympus E-M1)
Eric Nepean
 
Posts: 385
Joined: Sat Jun 28, 2014 8:54 pm
Location: Ontario, Canada

Re: getting size of a variant

Postby Eric Nepean » Sun Jun 25, 2017 4:30 am

NN635523068592468562UL wrote:Hi,
I am looking for a way to find each variants of a specific size.
I try to get the size or the crop size of a variants and always obtain an error.
Here is the code :
Code: Select all
global size_settings, my_variants
tell application "Capture One 10"
   set my_variants to selected variants
   set size_settings to (get crop size of my_variants)
end tell
return size_settings
May someone tell me where is the issue?
Thanks very much,
Philippe

Hi Philippe
A bunch more reading and testing, and I have learned the following.
The Applescript engine is not capable of an operation like "get some-property" of "some_list".
Applescript applications (like Capture One) can do it, but not the Applescript engine itself. (no idea why Apple should decide that)
See "Applescript, the Definitive Guide" 2nd ED, by Matt Neuman, pp203

When your script obtains the "selected variants" property of application "Capture One 10", it gets a list. The list is now handled by the Applescript engine, and so it can only be handled one item at a time. So "get crop size of my_variants" cannot work.

This can work, but you will need a repeat loop:
Code: Select all
tell application "Capture One 10"
   set my_variants to selected variants
   repeat with item_ctr from 1 to count of my_variants
      set size_settings to (get crop size of item item_ctr of my_variants)
   -- do other things...
   end repeat
end tell


I have discovered something obscure about Capture One which offers another alternative:
When one gets the variants of the current document, they are the selected variants. This will give directly what you wanted, as long as you do not put it in a list first.
Code: Select all
tell application "Capture One 10"
       tell the current document
          set my_variants to variants
          set size_settings to (get crop size of variants)
       end tell
end tell


I observe that you can also get all the variants showing in the browser, without needing to select, like this:
Code: Select all
tell application "Capture One 10"
       tell the current document
              tell the current collection
                 set my_variants to variants
                 set size_settings to (get crop size of variants)
              end tell
       end tell
end tell
Cheers
Eric
(OSX 10.12, iMac and MacBook Air, Panasonic GX7,GM5,G5, Olympus E-M1)
Eric Nepean
 
Posts: 385
Joined: Sat Jun 28, 2014 8:54 pm
Location: Ontario, Canada


Return to Scripting



Who is online

Users browsing this forum: Baidu [Spider] and 2 guests