Copy link to clipboard
Copied
app.activeDocument.suspendHistory("Create Mokup", "main()");
My script starts working on a specific doc (refDoc), perform a few actions and then open a new doc (dupDoc) and continue there.
When it completes i notice that in the history stages of refDoc, I only see "Create moKup" which is what i want,
however, in the history stages of dupDoc i see all the stages.
How can i suspend history for any doc my main() script, or any internal script my create?
Dan
Copy link to clipboard
Copied
I would think after you open the duplicate you should use suspendHistory
dupeDoc=app.activeDocument.duplicate("DupeDocName"); // Open a Dupelicate
app.activeDocument.suspendHistory('UpdateDuplicate','main()');
Copy link to clipboard
Copied
that does not work.
the dup is generated inside main()
when i add you suggestion line main is beeing invoked again after the duplication.
if it can't be done then how can i delete all history state from the dupDoc before the script competes?
Copy link to clipboard
Copied
Solution 1)
- post your code
Solution 2)
- you can use something like this...
var idCler = charIDToTypeID( "Cler" );
var desc27 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idPrpr = charIDToTypeID( "Prpr" );
var idHsSt = charIDToTypeID( "HsSt" );
ref1.putProperty( idPrpr, idHsSt );
var idDcmn = charIDToTypeID( "Dcmn" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref1.putEnumerated( idDcmn, idOrdn, idTrgt );
desc27.putReference( idnull, ref1 );
executeAction( idCler, desc27, DialogModes.NO );
Copy link to clipboard
Copied
Then you would need to restructure your code, Where there a function to updates the dupe
function main() {
code .....
dupeDoc=app.activeDocument.duplicate("DupeDocName"); // Open a Dupelicate
app.activeDocument.suspendHistory('UpdateDuplicate','updateDup()');
function updateDup(){
update code
close and save duped document
}
additional main function code liks close nosave the original document that main was processing
}
Copy link to clipboard
Copied
See if this is good for you.
// PRIME HISTORY
app.activeDocument.suspendHistory("Script--> 1", "main()");
function main () {
/// INSERT SCRIPT 1
// duply layer
// =======================================================
var desc165 = new ActionDescriptor();
var ref92 = new ActionReference();
ref92.putClass( charIDToTypeID( "Lyr " ));
desc165.putReference( charIDToTypeID( "null" ), ref92 );
desc165.putInteger( charIDToTypeID( "LyrI" ), 6 );
executeAction( charIDToTypeID( "Mk " ), desc165, DialogModes.NO );
// =======================================================
var desc167 = new ActionDescriptor();
desc167.putBoolean( charIDToTypeID( "Dplc" ), true );
executeAction( charIDToTypeID( "MrgV" ), desc167, DialogModes.NO );
// END SCRIPT 1
}
// END PRIME HISTORY
dupeDoc=app.activeDocument.duplicate("DupeDocName");
// SECOND HISTORY
app.activeDocument.suspendHistory("Script--> 2", "mainp()");
function mainp () {
/// SCRIPT 2
// SCRIPT TEST 2
// =======================================================
// test curve
// =======================================================
var desc130 = new ActionDescriptor();
var desc131 = new ActionDescriptor();
var desc132 = new ActionDescriptor();
var desc133 = new ActionDescriptor();
var desc134 = new ActionDescriptor();
var desc135 = new ActionDescriptor();
var desc139 = new ActionDescriptor();
var desc140 = new ActionDescriptor();
var list6 = new ActionList();
var list7 = new ActionList();
var ref78 = new ActionReference();
var ref79 = new ActionReference();
desc130.putEnumerated( stringIDToTypeID( "presetKind" ), stringIDToTypeID( "presetKindType" ), stringIDToTypeID( "presetKindCustom" ));
ref78.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( "Cmps" ));
desc131.putReference( charIDToTypeID( "Chnl" ), ref78 );
desc132.putDouble( charIDToTypeID( "Hrzn" ), 0.000000 );
desc132.putDouble( charIDToTypeID( "Vrtc" ), 0.000000 );
list7.putObject( charIDToTypeID( "Pnt " ), desc132 );
desc133.putDouble( charIDToTypeID( "Hrzn" ), 82.000000 );
desc133.putDouble( charIDToTypeID( "Vrtc" ), 67.000000 );
list7.putObject( charIDToTypeID( "Pnt " ), desc133 );
desc134.putDouble( charIDToTypeID( "Hrzn" ), 149.000000 );
desc134.putDouble( charIDToTypeID( "Vrtc" ), 174.000000 );
list7.putObject( charIDToTypeID( "Pnt " ), desc134 );
desc135.putDouble( charIDToTypeID( "Hrzn" ), 255.000000 );
desc135.putDouble( charIDToTypeID( "Vrtc" ), 255.000000 );
list7.putObject( charIDToTypeID( "Pnt " ), desc135 );
desc131.putList( charIDToTypeID( "Crv " ), list7 );
list6.putObject( charIDToTypeID( "CrvA" ), desc131 );
desc130.putList( charIDToTypeID( "Adjs" ), list6 );
executeAction( charIDToTypeID( "Crvs" ), desc130, DialogModes.NO );
// rename
ref79.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ));
desc139.putReference( charIDToTypeID( "null" ), ref79 );
desc140.putString( charIDToTypeID( "Nm " ), "TEST 1" );
desc139.putObject( charIDToTypeID( "T " ), charIDToTypeID( "Lyr " ), desc140 );
executeAction( charIDToTypeID( "setd" ), desc139, DialogModes.NO );
// duply layer
var idCpTL = charIDToTypeID( "CpTL" );
executeAction( idCpTL, undefined, DialogModes.NO );
// =======================================================
var desc178 = new ActionDescriptor();
var list10 = new ActionList();
var list8 = new ActionList();
var list9 = new ActionList();
list8.putInteger( 0 );
list8.putInteger( 0 );
list8.putInteger( 0 );
desc178.putList( charIDToTypeID( "ShdL" ), list8 );
list9.putInteger( -23 );
list9.putInteger( 16 );
list9.putInteger( -34 );
desc178.putList( charIDToTypeID( "MdtL" ), list9 );
list10.putInteger( 0 );
list10.putInteger( 0 );
list10.putInteger( 0 );
desc178.putList( charIDToTypeID( "HghL" ), list10 );
desc178.putBoolean( charIDToTypeID( "PrsL" ), true );
executeAction( charIDToTypeID( "ClrB" ), desc178, DialogModes.NO );
// rename
ref79.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ));
desc139.putReference( charIDToTypeID( "null" ), ref79 );
desc140.putString( charIDToTypeID( "Nm " ), "TEST 2" );
desc139.putObject( charIDToTypeID( "T " ), charIDToTypeID( "Lyr " ), desc140 );
executeAction( charIDToTypeID( "setd" ), desc139, DialogModes.NO );
}
// END SECOND HISTORY