Skip to content

Instantly share code, notes, and snippets.

@UskeS
Last active July 31, 2019 08:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UskeS/ff989916250f75dcf6e32c7802957821 to your computer and use it in GitHub Desktop.
Save UskeS/ff989916250f75dcf6e32c7802957821 to your computer and use it in GitHub Desktop.
最後に選択したオブジェクトを、他に選択したオブジェクトと入れ替える(左上基準)
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