Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
最後に選択したオブジェクトを、他に選択したオブジェクトと入れ替える(左上基準)
var doc = app.activeDocument;
var sel = doc.selection;
var tgt = sel[sel.length-1];
var newSelection = [];
app.doScript(main, ScriptLanguage.JAVASCRIPT, null, UndoModes.ENTIRE_SCRIPT);
function main(){
var tempRuler = doc.viewPreferences.rulerOrigin;
doc.viewPreferences.rulerOrigin = RulerOrigin.SPREAD_ORIGIN;
for (var i=sel.length-2; i>=0; i--) {
var n = tgt.duplicate([sel[i].visibleBounds[1], sel[i].visibleBounds[0]]);
sel[i].remove();
newSelection.push(n);
}
doc.viewPreferences.rulerOrigin = tempRuler;
doc.selection = newSelection;
alert("終了しました");
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment