How do I find out the value passed to Action in jsx?

Participant ,
Jan 17, 2021 Jan 17, 2021

Copy link to clipboard

Copied

There is a simple Action that adds noise to the image, where the noise settings are selected when the script is executed (toggle dialog on). In the script, the line: 

 

app.doAction ("Noise", "Command")

 

I want to send this value to the layer name.
Please tell me how to find out the value passed to the action?
I'm not good at JS. I will be grateful for any help!

TOPICS
Actions and scripting, How to, Make It, Windows

Views

173

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

correct answers 1 Correct Answer

Adobe Community Professional , Jan 17, 2021 Jan 17, 2021
I see no reason not to use Smart Filters for Frequency Separation …  Once can get the values of an applied Filter, but involving Actions would make things unnecessarily complicated in my opinion. function addNoise () { try { var desc16 = new ActionDescriptor(); var theRes = executeAction(charIDToTypeID( "AdNs" ), desc16, DialogModes.ALL ); return theRes } catch (e) {return false} }; var theRes = addNoise(); checkDesc2 (theRes); //////////////////////////////////// ////// ...

Likes

Translate

Translate
Adobe Community Professional ,
Jan 17, 2021 Jan 17, 2021

Copy link to clipboard

Copied

Why don’t you just apply the Filter as a Smart Filter, that way there is no need to store the values as text? 

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 ,
Jan 17, 2021 Jan 17, 2021

Copy link to clipboard

Copied

A good option, but this is just an example. Thanks! Similarly, I want to do for frequency decomposition, and there smart filters will not be convenient to use.

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
Adobe Community Professional ,
Jan 17, 2021 Jan 17, 2021

Copy link to clipboard

Copied

I see no reason not to use Smart Filters for Frequency Separation … 

 

Once can get the values of an applied Filter, but involving Actions would make things unnecessarily complicated in my opinion. 

function addNoise () {
    try {
    var desc16 = new ActionDescriptor();
    var theRes = executeAction(charIDToTypeID( "AdNs" ), desc16, DialogModes.ALL );
    return theRes
    } catch (e) {return false}
    };
var theRes = addNoise();
checkDesc2 (theRes);
////////////////////////////////////
////// based on code by michael l hale //////
function checkDesc2 (theDesc) {
    var c = theDesc.count;
    var str = '';
    for(var i=0;i<c;i++){ //enumerate descriptor's keys
        str = str + 'Key '+i+' = '+typeIDToStringID(theDesc.getKey(i))+': '+theDesc.getType(theDesc.getKey(i))+'\n'+getValues (theDesc, i)+'\n';
        };
    alert("desc\n\n"+str);
    return str
    };
////// check //////
function getValues (theDesc, theNumber) {
    switch (theDesc.getType(theDesc.getKey(theNumber))) {
    case DescValueType.ALIASTYPE:
    return theDesc.getPath(theDesc.getKey(theNumber));
    break;
    case DescValueType.BOOLEANTYPE:
    return theDesc.getBoolean(theDesc.getKey(theNumber));
    break;
    case DescValueType.CLASSTYPE:
    return theDesc.getClass(theDesc.getKey(theNumber));
    break;
    case DescValueType.DOUBLETYPE:
    return theDesc.getDouble(theDesc.getKey(theNumber));
    break;
    case DescValueType.ENUMERATEDTYPE:
    return (typeIDToStringID(theDesc.getEnumerationValue(theDesc.getKey(theNumber)))+"_"+typeIDToStringID(theDesc.getEnumerationType(theDesc.getKey(theNumber))));
    break;
    case DescValueType.INTEGERTYPE:
    return theDesc.getInteger(theDesc.getKey(theNumber));
    break;
    case DescValueType.LISTTYPE:
    return theDesc.getList(theDesc.getKey(theNumber));
    break;
    case DescValueType.OBJECTTYPE:
    return (theDesc.getObjectValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getObjectType(theDesc.getKey(theNumber))));
    break;
    case DescValueType.RAWTYPE:
    return theDesc.getReference(theDesc.getData(theNumber));
    break;
    case DescValueType.REFERENCETYPE:
    return theDesc.getReference(theDesc.getKey(theNumber));
    break;
    case DescValueType.STRINGTYPE:
    return theDesc.getString(theDesc.getKey(theNumber));
    break;
    case DescValueType.UNITDOUBLE:
    return (theDesc.getUnitDoubleValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getUnitDoubleType(theDesc.getKey(theNumber))));
    break;
    default: 
    break;
    };
    };

 

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 ,
Jan 17, 2021 Jan 17, 2021

Copy link to clipboard

Copied

Thank you so much for your help! This code works great! You saved me)

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 Beginner ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

I was wondering if you could help. I'm trying to use your code to get variables of the Color range command. 

I've managed to repurpose it this far.... 

function ColorRange () {
    try {
    var desc16 = new ActionDescriptor();
        var idClrs = charIDToTypeID( "Clrs" );
    var idClrs = charIDToTypeID( "Clrs" );
    var idMdtn = charIDToTypeID( "Mdtn" );
    desc16.putEnumerated( idClrs, idClrs, idMdtn );
    var theRes = executeAction(charIDToTypeID( "ClrR" ), desc16, DialogModes.ALL );
    return theRes
    } catch (e) {return false}
    };
var theRes = ColorRange();
checkDesc2 (theRes);
////////////////////////////////////
////// based on code by michael l hale //////
function checkDesc2 (theDesc) {
    var c = theDesc.count;
    var str = '';
    for(var i=0;i<c;i++){ //enumerate descriptor's keys
        str = str + 'Key '+i+' = '+typeIDToStringID(theDesc.getKey(i))+': '+theDesc.getType(theDesc.getKey(i))+'\n'+getValues (theDesc, i)+'\n';
        };
    alert("desc\n\n"+str);
    return str
    };
////// check //////
function getValues (theDesc, theNumber) {
    switch (theDesc.getType(theDesc.getKey(theNumber))) {
    case DescValueType.ALIASTYPE:
    return theDesc.getPath(theDesc.getKey(theNumber));
    break;
    case DescValueType.BOOLEANTYPE:
    return theDesc.getBoolean(theDesc.getKey(theNumber));
    break;
    case DescValueType.CLASSTYPE:
    return theDesc.getClass(theDesc.getKey(theNumber));
    break;
    case DescValueType.DOUBLETYPE:
    return theDesc.getDouble(theDesc.getKey(theNumber));
    break;
    case DescValueType.ENUMERATEDTYPE:
    return (typeIDToStringID(theDesc.getEnumerationValue(theDesc.getKey(theNumber)))+"_"+typeIDToStringID(theDesc.getEnumerationType(theDesc.getKey(theNumber))));
    break;
    case DescValueType.INTEGERTYPE:
    return theDesc.getInteger(theDesc.getKey(theNumber));
    break;
    case DescValueType.LISTTYPE:
    return theDesc.getList(theDesc.getKey(theNumber));
    break;
    case DescValueType.OBJECTTYPE:
    return (theDesc.getObjectValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getObjectType(theDesc.getKey(theNumber))));
    break;
    case DescValueType.RAWTYPE:
    return theDesc.getReference(theDesc.getData(theNumber));
    break;
    case DescValueType.REFERENCETYPE:
    return theDesc.getReference(theDesc.getKey(theNumber));
    break;
    case DescValueType.STRINGTYPE:
    return theDesc.getString(theDesc.getKey(theNumber));
    break;
    case DescValueType.UNITDOUBLE:
    return (theDesc.getUnitDoubleValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getUnitDoubleType(theDesc.getKey(theNumber))));
    break;
    default: 
    break;
    };
    };

 

 

 

is there a way of accessing the values without running the command. (executeActionGet)

, and how can i declare the values as variables.. I'm a little lost in your checkdesc2 function.  

 

 

Screenshot 2021-04-15 at 14.20.43.png

 

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
Adobe Community Professional ,
Apr 16, 2021 Apr 16, 2021

Copy link to clipboard

Copied

»is there a way of accessing the values without running the command.«

Sorry, I don’t understand what you mean. 

 

»and how can i declare the values as variables..«

What do you mean? Feed values to the operation or get the values as variable for later use or storing? 

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
Adobe Community Professional ,
Apr 16, 2021 Apr 16, 2021

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 Beginner ,
Apr 16, 2021 Apr 16, 2021

Copy link to clipboard

Copied

LATEST

don't worry i worked it out, see my other post here

 

https://community.adobe.com/t5/photoshop/scripting-color-range-command-getting-output-values/m-p/119...

 

 

your code was super helpful many thanks 

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