Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Baletin

macrumors regular
Original poster
Apr 14, 2012
138
21
Guys, I'm very confused :mad: because I cannot find any good sources about Applescript for Illustrator, especially up-to-date ones.

If you know these - please write them here for me (the Adobe guides are very limited).

I have a few questions, none of them has ever been answered on the forums I used to ask. Any suggestions will be greatly appreciated.

1. Why this code

Code:
set color of current layer in current document to {red:45.0, green:34.0, blue:34.0}
	set currentColor to color of current layer in current document

gives in results (in editor) this line -
{class:RGB color info, red:45.000001117587, green:34.000001773238, blue:34.000001773238}

I cannot compare the colors this way, please, help...

2. Any suggestions for programming "Divide objects below" function via applescript? I want to write a script to divide the artwork by a square (pattern creation).

3. Any suggestions for deleting the pieces of artwork which left after "Divide objects below" beyond the cutting square (I mean how to delete them via applescript.

Thank you friends...
 
Hi,

Other than the link above, I think your best bet is studying the scripting dictionary and googling for examples to learn from. Not ideal, I know. However, here are some general suggestions...

Personally, I also find Script Debugger (http://www.latenightsw.com/sd4/) very helpful in figuring out why a script isn't doing what I think it should. It also lets you browse the object model which can be helpful.

You may also find the AppleScript mailing list helpful: https://lists.apple.com/mailman/listinfo/applescript-users

Good luck!
 
In relation to the colour comparison, I guess there's some kind of rounding going on behind the scenes or conversion between types. Whatever the case, it's a tiny difference in colour values. Why not just round the RGB values in each colour and compare those, as follows:


Code:
tell application "Adobe Illustrator"
	tell front document
		
		--set up two colours
		set colourOne to {class:RGB color info, red:45, green:34, blue:34}
		set colourTwo to {class:RGB color info, red:45.7, green:34, blue:34}
		
		--compare colours
		if my matchColours(colourOne, colourTwo) then
			display dialog "Match"
		else
			display dialog "No match"
		end if
		
		
		
	end tell
end tell



on matchColours(firstColour, secondColour)
	--handler returns false if any RGB values don't match when rounded
	tell application "Adobe Illustrator"
		
		if (round (red of firstColour)) is not (round (red of secondColour)) then return false
		if (round (green of firstColour)) is not (round (green of secondColour)) then return false
		if (round (blue of firstColour)) is not (round (blue of secondColour)) then return false
		
		return true
		
	end tell
end matchColours
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.