• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

suspendHistory for newly open docs

Engaged ,
Jul 12, 2019 Jul 12, 2019

Copy link to clipboard

Copied

Hi,
In my script I am creating another i try to prevent adding history entries using:

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

TOPICS
Actions and scripting

Views

854

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Jul 12, 2019 Jul 12, 2019

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()');

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 12, 2019 Jul 12, 2019

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 13, 2019 Jul 13, 2019

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 );

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 13, 2019 Jul 13, 2019

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

}

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 13, 2019 Jul 13, 2019

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines