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!
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);
////////////////////////////////////
//////
...
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?
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.
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;
};
};
Copy link to clipboard
Copied
Thank you so much for your help! This code works great! You saved me)
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.
 
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?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
don't worry i worked it out, see my other post here
Scripting Color Range Command getting output values?
your code was super helpful many thanks