I need the largest “ie #4” at the top because the scripts that will follow will arrange the art in the layers on the document to specific coordinates on the page.
The page will consist of a grid of 16 squares, 4x4. The number 1 art will take up one square, the 2 art 2 squares and so on. I want to arrange the largest art first, keeping track of the remaining empty squares, then filling in the remaining empty squares with the smaller art layers down the line until the grid is full.
So, 4’s (if any) will completely fill a layer, 3’s will leave one remainder and so on. By looping through the layers, I can work my way down to the singles, placing them where needed (that’s the logic, anyway).
Here’s what I started to do. I figure I can change the whose loops to add the 3’s, 2’s and 1’s. I’m new to this, so I’m winging it as I go…
I think the logic is sound, but if it isn’t, or if there’s a better way to accomplish what I’m trying to do, I’M MORE THAN WILLING TO LEARN! Thank You!
set slot_1 to {x:0, y:808.5} – Coordinates of the 16 available die slots on the template.
set slot_2 to {x:180, y:808.5}
set slot_3 to {x:360, y:808.5}
set slot_4 to {x:540, y:808.5}
set slot_5 to {x:0, y:606.5}
set slot_6 to {x:180, y:606.5}
set slot_7 to {x:360, y:606.5}
set slot_8 to {x:540, y:606.5}
set slot_9 to {x:0, y:404.25}
set slot_10 to {x:180, y:404.25}
set slot_11 to {x:360, y:404.25}
set slot_12 to {x:540, y:404.25}
set slot_13 to {x:0, y:202}
set slot_14 to {x:180, y:202}
set slot_15 to {x:360, y:202}
set slot_16 to {x:540, y:202}
set Slots_left to 16
set layer_one_remainder to 4 --These are used to hold the remaining number of open slots should a 3, 2 or 1 die occupy a layer
set layer_two_remainder to 4
set layer_three_remainder to 4
set layer_four_remainder to 4
global template_exists
set template_exists to {}
set template_is_full to false
tell application “Adobe Illustrator”
activate
–my draw_template(template_exists)
copy
open file (“macintosh hd:cetip”)
paste
set total to (count of group items of document 1) --Counts the number of dies currently on the template.
tell application "Adobe Illustrator"
repeat with i from 1 to total
(every group item of document 1 whose name = "4")
if Slots_left = 16 and layer_four_remainder = 4 then
set selection of document 1 to ¬
{group item i of document 1}
set position of selection to {x of slot_1, y of slot_1}
set Slots_left to 12
set layer_four_remainder to 0
else
if Slots_left = 12 and layer_three_remainder = 4 then
set selection of document 1 to ¬
{group item i of document 1}
set position of selection to {x of slot_5, y of slot_5}
set Slots_left to 8
set layer_three_remainder to 0
else
if Slots_left = 8 and layer_two_remainder = 4 then
set selection of document 1 to ¬
{group item i of document 1}
set position of selection to {x of slot_9, y of slot_9}
set Slots_left to 4
set layer_two_remainder to 0
else
if Slots_left = 4 and layer_one_remainder = 4 then
set selection of document 1 to ¬
{group item i of document 1}
set position of selection to {x of slot_13, y of slot_13}
set layer_one_remainder to 0
set Slots_left to 0
set template_is_full to true
end if
end if
end if
end if
end repeat