Illustrator CC and open options

Hi all,

My Cocoa-Applescript got a strange thing with Illustrator CC open options:

tell application “Adobe Illustrator”
set user interaction level to never interact
open vectorFile with options {create artboard with artwork bounding box:true} without dialogs
end tell

Illustrator don’t response “without dialogs” and “set user interaction level to never interact” commands.
And spam me with some alert windows, like as profiles mismatch etc. when i try to open multiple files with applet.

In the regular AS all work well. :mad:

Xcode 5.1.1., OS 10.9.2

Is this in an Xcode project?

Yes this is in Xcode project.

I have a lot of AS droplet for prepress operations, and want to add some GUI elements with Xcode.
But this issue is very serious, it aborts the script.

Strange. I just made a project with this in the app delegate:

	on applicationWillFinishLaunching_(aNotification)
        set vectorFile to choose file
        tell application "Adobe Illustrator"
            set user interaction level to never interact
            open vectorFile with options {create artboard with artwork bounding box:true} without dialogs
        end tell
	end applicationWillFinishLaunching_

And I don’t see any dialogs.

How are you setting vectorFile?

Hi, Shane,

Thanks for response, this little script work well.

I make a drag’n’drop script


script AppDelegate
	property parent : class "NSObject"

property vectorFilesName : {} -- list of vector files

-- Raster images files formats
	property rasterTypeList : {"8BPS", "8BPB", "TIFF", "PNGf"}
	property rasterExtensionList : {"psd", "psb", "tif", "tiff", "png"}
	property rasterTypeIDsList : {"public.png", "com.adobe.photoshop-image", "dyn.ah62d4rv4ge81a65c", "public.tiff"}
	
	-- Vector images files formats
	property vectorTypeList : {"EPSP", "PDF"}
	property vectorExtensionList : {"ai", "eps", "pdf"}
	property vectorTypeIDsList : {"com.adobe.illustrator.ai-image", "com.adobe.encapsulated-postscript", "com.adobe.pdf"}


--------------------------------------------------
	-- 2. Droplet select files/folders --
	--------------------------------------------------
	on |application|:theApp openFiles:fileList
		set vectorFilesName to {}
		set rasterFilesName to {}

		set workResult to my setFilesList:fileList -- procedure for set list of dropped items, sort them and count
		if workResult is false then
			tell me
				activate
				display alert ¬
				"Sorry, application got an error:" message ¬
				"Unable to set parameters for dropped items" & return & "and will be terminated" & the error_number & ". " & the error_message
			end tell
			return
		end if
		
		set vectorCount to count of vectorFilesName
		set rasterCount to count of rasterFilesName
		
		set stringVectorCount to vectorCount as text
		fldVectorCount's setStringValue_(stringVectorCount)
		
		set stringRasterCount to rasterCount as text
		fldRasterCount's setStringValue_(stringRasterCount)

		if vectorCount < 1 and rasterCount < 1 then
			secondWindow's orderFront:me
			firstWindow's orderOut:me
		else if vectorCount > 0 then
			-- display dialog "You have select " & vectorCount & " vector files"
		end if

	end |application|:openFiles:
	-----------------------------------------------------------
end script

here I get a list of files, then sort them by type and write in variable

vectorFilesName


-------------------------------------------------------
-- Open files with Adobe Illustrator --
-------------------------------------------------------
on saveVectorAsJpeg_()
	
	try
		set countItems to count of vectorFilesName
		on error the error_message number the error_number
		tell me
			activate
			display alert ¬
			"Sorry, an error has occured “" message ¬
			"Unable to get the item_info: " & the error_number & ". " & the error_message
		end tell
	end try
	repeat with aFile in vectorFilesName
		tell application "Finder"
			
			try
				set droppedPath to aFile as string
				set the itemInfo to info for droppedPath -- Get full file info
				set this_extension to the name extension of itemInfo -- Extension
				on error the error_message number the error_number
				set this_extension to ""
				tell me
					activate
					display alert ¬
					"Sorry, module \"openWithAI\" got an error “" message ¬
					"Unable to get the info from item: " & return & return & the error_number & ". " & the error_message
				end tell
			end try
			
			--------------------------------------
			--  VERY IMPORTANT !!!! --
			--------------------------------------
			try
				set hfsPath to (((aFile as text) as POSIX file) as text) -- convert POSIX path to HFS path
				on error the error_message number the error_number
				tell me
					activate
					display alert ¬
					"Sorry, an error has occured “" message ¬
					"Unable to create hfsPath “ " & the error_number & ". " & the error_message
				end tell
			end try
			
			try
				set vectorFile to alias hfsPath -- convert HFS to alias (for open with Illustrator)
				on error the error_message number the error_number
				tell me
					activate
					display alert ¬
					"Sorry, an error has occured “" message ¬
					"Unable to create this_item  as alias of hfsPath “ " & the error_number & ". " & the error_message
				end tell
			end try
		end tell
		
		tell application "Adobe Illustrator"
			set user interaction level to never interact
			-- set display dialogs to never
			
			-- Here we try to open selected vector items
			with timeout of 600 seconds
			try
				open vectorFile with options {create artboard with artwork bounding box:true} without dialogs
				on error the error_message number the error_number
				tell me
					activate
					display alert ¬
					"Sorry, an error has occured in saveFilesAsEPS(thisItem) “" message ¬
					"Illustrator cant open the file: " & the error_number & ". " & the error_message
				end tell
				close current document saving no -- Close current document
				return false
			end try
		end timeout
		
		set docRef to the current document
		set docWidth to (width of docRef)
		set docHeight to (height of docRef)
		set docName to name of docRef
		
		if docWidth > docHeight then
			set scaleValue to ((currentPreviewSize * 100) / docWidth) * scaleResolution
			else
			set scaleValue to ((currentPreviewSize * 100) / docHeight) * scaleResolution
		end if
		
		try
			set newFileName to outputFolder & docName & "." & this_extension
			
                        --set testName to newFileName as string
			--set testName to «class ktxt» of (testName as record)
			on error the error_message number the error_number
			
			tell me
				activate
				display alert ¬
				"Sorry, an error has occured in module saveVectorAsJPEG() “" message ¬
				"Unable to set name for output file: " & the error_number & ". " & the error_message
			end tell
			close current document saving no
			return false
		end try
		
		with timeout of 1800 seconds
		try
			export current document to file newFileName as JPEG with options ¬
			{class:JPEG export options, quality:80, matte:false, artboard clipping:true}
			on error the error_message number the error_number
			tell me
				activate
				display better alert ¬
				"Sorry, an error has occured in module saveVectorAsJPEG() “" message ¬
				"Illustrator can't save the file: " & the error_number & ". " & the error_message
			end tell
			close current document saving no
			return false
		end try
	end timeout
	close current document saving no
	
end tell
end repeat

end saveVectorAsJpeg_

Here i open files with Ai. (This a part of script)

OMG, wall of text

So it was not in the reel - dunce sat in the cockpit … :frowning:

The first thing I’d do would be to remove all reference to the Finder. You’re only using it to get the extension, and there are plenty of quicker ways to do that. You’ll also need to change “set vectorFile to alias hfsPath” to “set vectorFile to hfsPath as alias”.

Thanks a lot, Shane

it is worked :slight_smile: