error number -1728 Applescript & some issues with spot

Discussion in 'Mac Programming' started by nellbern, Jan 22, 2013.

  1. nellbern, Jan 22, 2013
    Last edited by a moderator: Jan 22, 2013

    nellbern macrumors newbie

    Mar 3, 2008
    I have been working on this script for weeks. Basically I would like to batch (using AS) illustrator CS4 files. (open, find spot colors, change to process, save, close). So far I'm able to open files but the part when is supposed to change them into process is falling giving me an error number -1728 from document 1 of document 1. I tried to put as many --comments on the script
    I want to clarify my knowlege in AS is basic. What is this error? I search specifically for this error number with no success. What I have was pieced together and modified from 2 scripts I found. I'm challenging myself with not too much success but If I don't to ask, I don't learn. Can you anyone guide me to a solution?

    property file_types : {"EPSf", "EPSP"}
    property file_extensions : {"eps"}
    --Would like just Illustrator eps files not Photoshop eps. How can you do this? currently if in the folder there are Photoshop eps files the script is opening those files
    set the_folder to (choose folder with prompt "Select the files containing Illustrator docs to change spot to process colors:")
    set the_images to get_folder_list(the_folder, file_types, file_extensions, true, false)
    if the_images = {} then
         display dialog "No valid Illustrator found in chosen folder." buttons {"OK"} default button 1 with icon 0 giving up after 10
    end if
    on openLegacyFile(fileToOpen) --Open a file with automatic update of legacy text --(I found this in the ADOBE ILLUSTRATOR CS4SCRIPTING REFERENCE)
         tell application "Adobe Illustrator"
      open POSIX file fileToOpen as alias with options {update legacy text:true}
         end tell
    end openLegacyFile
    tell application "Adobe Illustrator"
      --set user interaction level of script preferences to never interact --Will ignore any dialogs when opening files. Currently NOT working with files with embedded color profiles I'm getting a message: Your current settings discard CMYK profiles in linked content but profiles were set to be honored when this document was created. Cancel/Continue
         repeat with the_image in the_images
      open the_image as alias
             tell document 1
                   set locked of every layer to false --unlock all layers
                   set locked of every page item to false --unlock any page items
                   set selected of (every page item) to true
                   set spotColorCount to count of spots
                       set color type of (spots of document 1 whose name is not "[Registration]" and its color type is spot color) to process color
                   end try
                   if exists (swatches whose class of color of it is CMYK color info) then
                       set t to (name of every swatch whose class of color of it is CMYK color info)
                       my convertSpotSwatchesToProcess(t)
                   end if
      --This is the part that is not working at all. It doesnt find any spot colors
    -- the results is --> error number -1728 from document 1 of document 1
      --set user interaction level of script preferences to interact with all --restore prefs
             end tell
         end repeat
    end tell
    on convertSpotSwatchesToProcess(list_of_swatches)
         tell application "Adobe Illustrator"
             tell document 1
                   set replacementSwatches to {}
                   set deleteSwatches to {}
                   set cmykSwatches to every swatch whose class of color of it is CMYK color info and name is in list_of_swatches
                   repeat with thisSwatch in cmykSwatches
                       set swatchName to name of thisSwatch
                       set swatchColor to color of thisSwatch
                       copy {name:swatchName, color:swatchColor} to end of replacementSwatches
                       set end of deleteSwatches to thisSwatch
                   end repeat
      delete deleteSwatches
                   repeat with thisReplacement in replacementSwatches
      make new spot at end with properties thisReplacement
                   end repeat
             end tell
         end tell
    end convertSpotSwatchesToProcess
    on get_folder_list(the_folder, file_types, file_extensions)
         set the_files to {}
         tell application "Finder" to set folder_list to every item of folder the_folder
         repeat with new_file in folder_list
                   set temp_file_type to file type of new_file
                   set temp_file_extension to name extension of new_file
             on error
                   set temp_file_type to "folder"
                   set temp_file_extension to ""
             end try
             if file_types contains temp_file_type or file_extensions contains temp_file_extension then set end of the_files to (new_file as string)
         end repeat
         return the_files
    end get_folder_list
    -I'm getting this results get file type of document file "Black.eps" of folder "test" of folder "Desktop" of folder "user" of folder "Users" of startup disk --> missing value
  2. ConCat, Jan 22, 2013
    Last edited: Jan 22, 2013

    ConCat macrumors 6502a


    Jul 27, 2012
    In an ethereal plane of existence.
    here's the official definition of error "-1728":
    Perhaps it has something to do with an incorrect number of arguments somewhere... Not certain. If you can figure out what it means, that should be the issue.

    The official name is "errAENoSuchObject", as an extra hint.

    Oh, seems it has an official second definition:

    Might just be that the file it's looking for can't be found, if the alternate definition of the error is the correct one.

    Just for you, I downloaded the trial copy of illustrator and tried it. It works. Don't see the problem.

Share This Page