Highlighted

Simple script to re-stack isometric game assets

Engaged ,
Nov 17, 2020

Copy link to clipboard

Copied

So I wrote another script.
It reorders your replicated symbols so the bottom-most, right-most ones get sent to the the top of the pile.
Might work well for isometric game art or just making a whole forest of random trees.
 
Thing is- it needs testing.
It could probably be made more efficient too.
 
Any ideas, let me know.
 
Enjoy.

 

#target Illustrator var docRef = app.activeDocument;
var sel = docRef.selection;
var selLen = sel.length;
if(!sel.length) { alert("You must make a selection.");
} 
function stack(sel){// Only fire this off once the sel array has been sorted.
var layer = app.activeDocument.layers[0];
var len = sel.length;
for (var i=0;i<len;i++){
var item = sel[i];
item.move(layer, ElementPlacement.PLACEATBEGINNING);
}
}
function sortByScore(a,b){
var scoreA = Math.round(Math.abs(a.top));
var scoreB = Math.round(Math.abs(b.top));
return (scoreA-scoreB);
}
sel.sort(sortByScore);// First: Sort sel by score. This takes the sel array and runs it through the sortByScore function.
stack(sel);// Second: restack sel in the parent now that it's sorted. Needs work.
TOPICS
Draw and design, How to, Scripting

Views

24

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Simple script to re-stack isometric game assets

Engaged ,
Nov 17, 2020

Copy link to clipboard

Copied

So I wrote another script.
It reorders your replicated symbols so the bottom-most, right-most ones get sent to the the top of the pile.
Might work well for isometric game art or just making a whole forest of random trees.
 
Thing is- it needs testing.
It could probably be made more efficient too.
 
Any ideas, let me know.
 
Enjoy.

 

#target Illustrator var docRef = app.activeDocument;
var sel = docRef.selection;
var selLen = sel.length;
if(!sel.length) { alert("You must make a selection.");
} 
function stack(sel){// Only fire this off once the sel array has been sorted.
var layer = app.activeDocument.layers[0];
var len = sel.length;
for (var i=0;i<len;i++){
var item = sel[i];
item.move(layer, ElementPlacement.PLACEATBEGINNING);
}
}
function sortByScore(a,b){
var scoreA = Math.round(Math.abs(a.top));
var scoreB = Math.round(Math.abs(b.top));
return (scoreA-scoreB);
}
sel.sort(sortByScore);// First: Sort sel by score. This takes the sel array and runs it through the sortByScore function.
stack(sel);// Second: restack sel in the parent now that it's sorted. Needs work.
TOPICS
Draw and design, How to, Scripting

Views

25

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 17, 2020 0

Have something to add?

Join the conversation
Resources