• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Simple script to re-stack isometric game assets

Engaged ,
Nov 17, 2020 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 , Scripting

Views

118

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
community guidelines
no replies

Have something to add?

Join the conversation
Adobe