Quantcast
Channel: Adobe Community: Message List - Photoshop Scripting
Viewing all articles
Browse latest Browse all 27456

Re: Re: adobe script for rotation and position

$
0
0

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[m], 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 );
};

Viewing all articles
Browse latest Browse all 27456

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>