Copy link to clipboard
Copied
This script changes stamp source to x. I dont know how to get current source number. Anyone know how to do this?
function CloneSource(x){ //x: {1-5}
var cloneNr = "cloneSourceSource" + x
try {
var idslct = cTID( "slct" );
var desc198 = new ActionDescriptor();
var idnull = cTID( "null" );
var ref124 = new ActionReference();
var idMn = cTID( "Mn " );
var idMnIt = cTID( "MnIt" );
var idcloneSourceSourceone = sTID( cloneNr );
ref124.putEnumerated( idMn, idMnIt, idcloneSourceSourceone );
desc198.putReference( idnull, ref124 ); executeAction( idslct,desc198, DialogModes.ALL );}
catch(e){if (e.toString().indexOf(ErrStrs.USER_CANCELLED)!=-1) {;} else{alert(localize("$$$/ScriptingSupport/Error/CommandNotAvailable=The command is currently not available"));}}
}
Copy link to clipboard
Copied
This code is for seting clone source:
var idsetd = charIDToTypeID( "setd" );
var desc98 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref9 = new ActionReference();
var idPrpr = charIDToTypeID( "Prpr" );
var idClnS = charIDToTypeID( "ClnS" );
ref9.putProperty( idPrpr, idClnS );
var idcapp = charIDToTypeID( "capp" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref9.putEnumerated( idcapp, idOrdn, idTrgt );
desc98.putReference( idnull, ref9 );
var idT = charIDToTypeID( "T " );
var desc99 = new ActionDescriptor();
var idSrce = charIDToTypeID( "Srce" );
var ref10 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idBckg = charIDToTypeID( "Bckg" );
ref10.putProperty( idLyr, idBckg );
desc99.putReference( idSrce, ref10 );
var idPstn = charIDToTypeID( "Pstn" );
var desc100 = new ActionDescriptor();
var idHrzn = charIDToTypeID( "Hrzn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc100.putUnitDouble( idHrzn, idPxl, 1443.000000 );
var idVrtc = charIDToTypeID( "Vrtc" );
var idPxl = charIDToTypeID( "#Pxl" );
desc100.putUnitDouble( idVrtc, idPxl, 668.000000 );
var idPnt = charIDToTypeID( "Pnt " );
desc99.putObject( idPstn, idPnt, desc100 );
var idImgP = charIDToTypeID( "ImgP" );
desc98.putObject( idT, idImgP, desc99 );
executeAction( idsetd, desc98, DialogModes.NO );
As you can see... data should be stored in application class inside clonesource property. (rows 5-11)
But if you try to read this property:
function getCloneSource () {
var cloneID = charIDToTypeID("ClnS");
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID('property'), cloneID );
ref.putEnumerated(stringIDToTypeID('application'), stringIDToTypeID('ordinal'), stringIDToTypeID('targetEnum'));
return executeActionGet(ref);
}
It simply fails, but same code works for different properties. E.g. "currentToolOptions"
So this data are probably write-only. Just try put e.g. stringIDToTypeID("cachePrefs"); instead charIDToTypeID("ClnS"); And it should pass.
You can only read active tool type and probably all brush settings. But not data from Clone Source panel.