My script actually ended up erroring out when an item you are trying to reselect has a hidden sub item. To work around this I actually used Silly-V's move dialog script to replace my alignment actions. The result was as follows. I confirmed that it works with hidden sub items and opacity masks.
function ActionManager(){
this.currentLoadedSets = [];
this.checkLoadedSets = function(setName){
if(this.currentLoadedSets.length > 0 && this.currentLoadedSets.join("").match(setName)){
return true;
} else {
return false;
}
};
this.alertLoadedSets = function(){
var arr = [];
for (var i = 0; i < this.currentLoadedSets.length; i++) {
arr.push(this.currentLoadedSets);
}
alert(arr.join("\n"));
};
this.loadSet = function(setString, setName){
this.removeSet(setName);
var aiaFile;
if(typeof setString == "string"){
aiaFile = new File('~/ScriptAction.aia');
aiaFile.open("w");
aiaFile.write(setString);
aiaFile.close();
app.loadAction(aiaFile);
this.currentLoadedSets.push(setName);
aiaFile.remove();
return true;
} else if(setString instanceof File){
aiaFile = setString;
if(aiaFile.exists){
app.loadAction(aiaFile);
this.currentLoadedSets.push(setName);
return true;
} else {
alert("File '" + decodeURI(aiaFile) + "' was not found!");
return false;
}
}
};
this.playAction = function(actionName, setName, force){
if(this.checkLoadedSets(setName) || (force === true)){
app.doScript(actionName, setName);
return true;
} else {
if(typeof this.debugLevel != "undefined" && this.debugLevel === true){
alert("ActionManager: the set '" + setName + "' is not found to be currently loaded.");
}
return false;
}
};
this.removeSet = function(setName){
var errorFlag = false;
while(!errorFlag){
try {
app.unloadAction(setName, "");
} catch (e) {
errorFlag = true;
}
}
var arr = [];
var nm;
for (var i = 0; i < this.currentLoadedSets.length; i++) {
nm = this.currentLoadedSets;
if(nm != setName){
arr.push(nm);
}
};
this.currentLoadedSets = arr;
};
};
/* ================================================================================================================ */
var selectedItems = app.activeDocument.selection;
var cutLines = [];
var artItem;
for (var i = 0; i<selectedItems.length; i++){
if (selectedItems.layer.name == 'DRT copy'){
cutLines.push(selectedItems)
selectedItems.selected=false;
}else{
artItem = selectedItems;
}
}
for (var e = 0; e<cutLines.length; e++){
var cLeft = cutLines.left;
var cTop = cutLines.top;
var offsetX = cLeft - artItem.pageItems[0].left;
var offsetY = cTop - artItem.pageItems[0].top;
$.writeln("X: " + offsetX + " Y: " + offsetY);
app.copy();
var actionString = [
"/version 3",
"/name [ 8",
" 4d6f76654974656d",
"]",
"/isOpen 1",
"/actionCount 1",
"/action-1 {",
" /name [ 8",
" 6d6f76654974656d",
" ]",
" /keyIndex 0",
" /colorIndex 0",
" /isOpen 1",
" /eventCount 1",
" /event-1 {",
" /useRulersIn1stQuadrant 0",
" /internalName (adobe_move)",
" /localizedName [ 4",
" 4d6f7665",
" ]",
" /isOpen 0",
" /isOn 1",
" /hasDialog 1",
" /showDialog 0",
" /parameterCount 3",
" /parameter-1 {",
" /key 1752136302",
" /showInPalette -1",
" /type (unit real)",
" /value " + offsetX, // has to be a decimal number to work
" /unit 592476268",
" }",
" /parameter-2 {",
" /key 1987339116",
" /showInPalette -1",
" /type (unit real)",
" /value " + offsetY,
" /unit 592476268",
" }",
" /parameter-3 {",
" /key 1668247673",
" /showInPalette -1",
" /type (boolean)",
" /value 0",
" }",
" }",
"}"
].join("\n");
var actionManager = new ActionManager();
actionManager.loadSet(actionString, "MoveItem");
actionManager.playAction("moveItem", "MoveItem");
actionManager.removeSet("MoveItem");
app.paste();
artItem = app.activeDocument.selection[0];
if(e+1 == cutLines.length){
if(confirm('Are you done setting this peice?')){
artItem.remove();
}
}
}