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

Very slow Script

Participant ,
Nov 04, 2022 Nov 04, 2022

Copy link to clipboard

Copied

How to write the script so fast, Because my script is very slow, please guide me, Someone told me AM Code is fast as compared to Script,

 

Anyone can tell me how to write Action Manager Code For Fast Working.

 

How to know what is DOM and AM please tell me.

 

Thanks for Advance

TOPICS
Actions and scripting , SDK , Windows

Views

136

Likes

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
Advisor ,
Nov 04, 2022 Nov 04, 2022

Copy link to clipboard

Copied

@MXKS,

 

It would be helpful if you posted the code for your script in question for others here to troubleshoot.

 

Regards,

Mike

Likes

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
Participant ,
Nov 05, 2022 Nov 05, 2022

Copy link to clipboard

Copied

is this an Action Manager Code or not?

If it is not tell me how to write this AM Code!

 

#target photoshop
//
// test.jsx
//

//
// Generated Sat Feb 13 2021 03:26:11 GMT+0530
//

cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

//
//==================== Action 1 ==============
//
function Action1() {
// Copy
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
executeAction(cTID('copy'), undefined, dialogMode);
};

// Delete
function step2(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
desc1.putReference(cTID('null'), ref1);
var list1 = new ActionList();
list1.putInteger(95);
desc1.putList(cTID('LyrI'), list1);
executeAction(cTID('Dlt '), desc1, dialogMode);
};

step1(); // Copy
step2(); // Delete
};

 

//=========================================
// Action1.main
//=========================================
//

Action1.main = function () {
Action1();
};

Action1.main();

// EOF

"test.jsx"
// EOF

Likes

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 ,
Nov 05, 2022 Nov 05, 2022

Copy link to clipboard

Copied

@MXKS – It appears that you have used xtools to convert an Action to JavaScript, so yes, this is AM code. Those 49 lines of converted code are the equivalent of the following 2 lines of DOM code:

 

activeDocument.activeLayer.copy();
activeDocument.activeLayer.remove();

 

Either way, it is only two steps, copy the layer and delete.

 

AM code is faster in certain circumstances, such as an alternative to for-loops over large layer collections.

 

I just tested the 49 lines of code with a JS timer, 0.12 seconds... vs 0.11 seconds for the 2 lines of DOM code. So in this case DOM vs. AM is essentially the same.

 

Likes

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
Participant ,
Nov 05, 2022 Nov 05, 2022

Copy link to clipboard

Copied

Is AM Code Faster than DOM?

 

How to write AM Code ? 

Could your share your knowledge !

Likes

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 ,
Nov 05, 2022 Nov 05, 2022

Copy link to clipboard

Copied

Likes

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 ,
Nov 07, 2022 Nov 07, 2022

Copy link to clipboard

Copied

LATEST

AM code is faster when it comes to getting the properties of complex objects. This is due to the fact that with its help it is not necessary to get the entire object to access its properties - using the .getProperty () function, we can get only what is needed at the moment. In other cases, AM simply provides more features than DOM (the ability to get more properties, the ability to perform an action with a large number of parameters, the ability to change individual properties without affecting the entire object, etc.)

 

 

Likes

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