Thank you for the tips.
So far I have been able to do basically what I need to do.
I have an xml file that has xy coordinates.
I have a layer with a circle.
I have successfully made a script that reads the xml file, duplicates the circle layer, names it 'nextcircle' + a number, moves it to the 'circles' group of layers, and then moves it to the correct xy location, loped for the number of coordinates. Right now I'm skipping the rotating because I'm practicing with a circle. After I get this done I'll try an ellipse add rotation angles to each pair of coordinates. I think I can handle that at this point.
But, I want to set up a timeline of frames and I can't seem to find any documentation about accessing the timeline in script.
Here's what i want to do. make a time line in with each of my layers in sequentially visible. So, in frame 1, only nextcircle1 is visible, in frame 2 only nextcircle2 is visible. etc.
Here is my code. There's probably a better way, but this is working mostly (although in reality I have to break it up into 10 coordinates at a time so that my photoshop didn't crash)
var doc=app.activeDocument
var circleLayer= doc.artLayers.getByName ("circle") //my circle that I will move around
var cLayer=[];
var baseName= "nextcircle" // the name for each duplicated layer
doc.activeLayer=circleLayer
var circleSet = doc.layerSets.getByName ("circles"); I have a layer group called circles in which i will put each new layer
var f = new File('C:/Users/[me]/Documents/Adobe Scripts/path.xml') // my xml file with coordinates for my circle to travel
f.open('r')
var pathxml = new XML(f.read())
f.close()
pathLen=pathxml.circlex.length() // gets the number of coordinates (
for (var i =1; i <=pathLen; i++){ // loops through the coordinate list
var nm= baseName.concat(i.toString()); // name of new layer
cLayer=circleLayer.duplicate (doc, ElementPlacement.PLACEATBEGINNING) //duplicates my circle
with(cLayer) {
name = nm // names it
}
cLayer.moveToEnd(circleSet) // moves the new layer to the top of the circles group
var posx = Number(pathxml.circlex[i-1]) //extracts the x pos for the ith-1 value
var posy = Number(pathxml.circley[i-1]) //extracts the y pos for the ith-1 value
MoveLayerTo(cLayer,posx,posy) //moves to the new location (I copied this function from somewhere)
}
function MoveLayerTo(fLayer,fX,fY) {
var Position = fLayer.bounds;
Position[0] = fX - Position[0];
Position[1] = fY - Position[1];
fLayer.translate(-Position[0],-Position[1]);
}
This would create a frame animated based on the Layers inside the topmost LayerSet.
It assumes that the file does not have animation yet.
// 2014, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
// define the layers;
var theLayers = myDocument.layerSets[0].layers;
// hide all except topmost layer;
hideOthers (theLayers[0], myDocument);
// make frame animation;
// =======================================================
var idmakeFrameAnimation = stringIDToTypeID( "makeFrameAnimation" );
executeAction( idmakeFrameAnimation, undefined, DialogModes.NO );
// set frame rate;
// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc10 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref9 = new ActionReference();
var idanimationFrameClass = stringIDToTypeID( "animationFrameClass" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref9.putEnumerated( idanimationFrameClass, idOrdn, idTrgt );
desc10.putReference( idnull, ref9 );
var idT = charIDToTypeID( "T " );
var desc11 = new ActionDescriptor();
var idanimationFrameDelay = stringIDToTypeID( "animationFrameDelay" );
desc11.putDouble( idanimationFrameDelay, 0.100000 );
var idanimationFrameClass = stringIDToTypeID( "animationFrameClass" );
desc10.putObject( idT, idanimationFrameClass, desc11 );
executeAction( idsetd, desc10, DialogModes.NO );
// work through layers;
for (var m = 1; m < theLayers.length; m++) {
// =======================================================
var idDplc = charIDToTypeID( "Dplc" );
var desc7 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref6 = new ActionReference();
var idanimationFrameClass = stringIDToTypeID( "animationFrameClass" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref6.putEnumerated( idanimationFrameClass, idOrdn, idTrgt );
desc7.putReference( idnull, ref6 );
executeAction( idDplc, desc7, DialogModes.NO );
// hide others;
hideOthers (myDocument.activeLayer, myDocument);
hideOthers (theLayers, myDocument);
};
};
////// toggle visibility of others //////
function hideOthers (theLayer, myDocument) {
theLayer.visible = true;
myDocument.activeLayer = theLayer;
// =======================================================
var idShw = charIDToTypeID( "Shw " );
var desc10 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var list4 = new ActionList();
var ref7 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref7.putEnumerated( idLyr, idOrdn, idTrgt );
list4.putReference( ref7 );
desc10.putList( idnull, list4 );
var idTglO = charIDToTypeID( "TglO" );
desc10.putBoolean( idTglO, true );
executeAction( idShw, desc10, DialogModes.NO );
};