Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Jan 22, 2013, 07:25 PM   #1
macrumors newbie
Join Date: Mar 2008
error number -1728 Applescript & some issues with spot

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

Last edited by balamw; Jan 22, 2013 at 07:33 PM. Reason: CODE tags
nellbern is offline   0 Reply With Quote
Old Jan 22, 2013, 07:36 PM   #2
Join Date: Jul 2012
Location: In an ethereal plane of existence.
here's the official definition of error "-1728":
specifier asked for the 3rd, but there are only 2. Basically, this indicates a run-time resolution error.
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:

errOSACantAccess = errAENoSuchObject, /* Signaled when an object is not found in a container*/
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.

Last edited by ConCat; Jan 22, 2013 at 09:03 PM.
ConCat is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Applescript - Button returned error bgrantmyre Mac Programming 1 Jul 30, 2013 07:04 PM
Help with Applescript error watcoh Mac Basics and Help 0 Apr 29, 2013 05:15 PM
Applescript Error ekulmail71 Mac Programming 0 Nov 7, 2012 03:04 AM
AT&T My Spot for Verizon? edtorious iPhone 0 Oct 3, 2012 10:32 AM
Creating a random number within a URL using Applescript moorbull Mac Programming 1 Jul 19, 2012 08:16 AM

Forum Jump

All times are GMT -5. The time now is 09:20 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC