Oh many good points, Carlos. Thank you for catching that!
And yes, although it will turn out quite messy, that is kind of the end goal. You see, I am trying to develop a script that will take an Illustrator file with many artboards and prepare it for animation with After Effects. Currently, I receive an Illustrator file that has many artboards on it. The artboards are the designers way to communicate how the animation should proceed. They are bascially storyboards with each artboard slightly changing its appearance and content from one to the next. It looks like a flipbook all layed out.
But After Effects will only import one artboard and so everything in the Illustrator "storyboards" needs to be moved to one artboard. Then the script will turn all the groups/artwork/linked files into their own "top level" layers because After Effects will merge everything that is in one Illustrator layer, which prevents me from being able to independently animate the separate artwork pieces. And then since I only need one instance of each piece of artwork to use in After Effects, I will have it delete any artwork that doesn't change size/position/rotation from one artboard to the other. I will probably have to designate these "duplicates" manually by making them invisible in the Layers panel and then having the script delete all invisible layers.
If I can get this to succesully run, it will easily save me anywhere from 2-4 hours per day. Right now I have to manually drag everything around, reorder all the layers, and pull sublayers out to their individual top level layers, and it's just tedious.
But back to step 1 in my plan for world domination automation. 
I had seen the getTranslationMatrix() function, but I never could get it to work. I'm not quite sure what you mean by LBound(j) and UBound(j) in your script. Maybe you can explain a little more what it is doing? Or maybe write it in Javascript instead? 
Here is my updated code:
#target Illustrator
var docRef = app.activeDocument;
stackArtboards();
//------Stack Artboards and Contents-------------// function stackArtboards(){ var activeboard = new Array(); var stackhere = new Array(); var getdelta = new Array(); var numboards = docRef.artboards.length; stackhere = docRef.artboards[0].artboardRect; for(i=numboards; i>1; i--){ activeboard[1] = docRef.artboards[1].artboardRect; getdelta = calcDelta(stackhere, activeboard[1]); var deltaX = getdelta[0]; var deltaY = getdelta[1]; docRef.artboards.setActiveArtboardIndex(1); docRef.selectObjectsOnActiveArtboard(); var sel = docRef.selection; var moveMatrix = app.getTranslationMatrix (deltaX, deltaY); sel.transform(moveMatrix); sel.selected = false; delBoard(1);
} }
//------Calculate How Much to Move Artwork-------------// function calcDelta(stckhere, movethis){ var deltaX = stckhere[0] - movethis[0]; var deltaY = stckhere[1] - movethis[1];
return[deltaX, deltaY]; }
//-------Delete Artboard-----------// function delBoard(boardindex){ docRef.artboards.setActiveArtboardIndex(boardindex); docRef.artboards.remove(boardindex); } |
When I run this script, I get an error at the bolded section (sel.transform(moveMatrix);) - it says "sel.transform is not a function." Since I'm not quite sure what your VB script is doing, I'm not exactly sure how to proceed.
I appreciate your help!
Lbound & Ubound are the VB functions to get the first and last index of the selection, there's no "length" property in VB.
loop thru all items in selection and apply matrix
for (var j=0;j<sel.length;j++)
{
sel.transform (moveMatrix);
sel.selected = false;
}
this should set you on your World Dominance way. 