Not sure what i’ve done wrong here, for some reason, when i try call the value of a radio button in the function, it wont run. If I call the value of the radio button by itself with in the UXP debug console, it returns the value of the radio button, ie “2”, “4” etc
[...document.querySelectorAll('#radiusAmount sp-radio')].filter(radio => radio.checked)[0].value;
"8"
The below code works fine, if i swap variable radius to something like 4
var radius = 4
Then it executes as expected with that radius.
Just wondering if there is something special when dealing with this as i’ve used the same method in different situations with no issues.
Thanks,
async function makeSharpenLayer(){
var radius = [...document.querySelectorAll('#radiusAmount sp-radio')].filter(radio => radio.checked)[0].value;
var layerName = "Sharp" + radius + "px"
const result = await sharpenImage(radius, layerName);
}
async function sharpenImage(radius, layerName) {
const result = await batchPlay(
[
{
"_obj": "select",
"_target": [
{
"_ref": "layer",
"_name": "Process"
}
],
},
{
"_obj": "mergeVisible",
"duplicate": true,
},
{
"_obj": "set",
"_target": [
{
"_ref": "layer",
"_enum": "ordinal",
"_value": "targetEnum"
}
],
"to": {
"_obj": "layer",
"name": "Colour"
},
},
{
"_obj": "copyToLayer",
},
{
"_obj": "set",
"_target": [
{
"_ref": "layer",
"_enum": "ordinal",
"_value": "targetEnum"
}
],
"to": {
"_obj": "layer",
"name": "Sharp"
},
},
{
"_obj": "select",
"_target": [
{
"_ref": "layer",
"_name": "Colour"
}
],
},
{
"_obj": "median",
"radius": {
"_unit": "pixelsUnit",
"_value": radius
},
},
{
"_obj": "select",
"_target": [
{
"_ref": "layer",
"_name": "Sharp"
}
],
},
{
"_obj": "applyImageEvent",
"with": {
"_obj": "calculation",
"to": {
"_ref": [
{
"_ref": "channel",
"_enum": "channel",
"_value": "RGB"
},
{
"_ref": "layer",
"_name": "Colour"
}
]
},
"calculation": {
"_enum": "calculationType",
"_value": "subtract"
},
"scale": 2,
"offset": 128
},
},
{
"_obj": "set",
"_target": [
{
"_ref": "layer",
"_enum": "ordinal",
"_value": "targetEnum"
}
],
"to": {
"_obj": "layer",
"mode": {
"_enum": "blendMode",
"_value": "linearLight"
}
},
},
{
"_obj": "select",
"_target": [
{
"_ref": "layer",
"_name": "Colour"
}
],
},
{
"_obj": "unsharpMask",
"amount": {
"_unit": "percentUnit",
"_value": 100
},
"radius": {
"_unit": "pixelsUnit",
"_value": radius
},
"threshold": 0,
},
{
"_obj": "select",
"_target": [
{
"_ref": "layer",
"_name": "Sharp"
}
],
},
{
"_obj": "select",
"_target": [
{
"_ref": "layer",
"_name": "Colour"
}
],
"selectionModifier": {
"_enum": "selectionModifierType",
"_value": "addToSelection"
},
},
{
"_obj": "mergeLayersNew",
},
{
"_obj": "move",
"_target": [
{
"_ref": "layer",
"_enum": "ordinal",
"_value": "targetEnum"
}
],
"to": {
"_ref": "layer",
"_enum": "ordinal",
"_value": "previous"
},
},
{
"_obj": "select",
"_target": [
{
"_ref": "layer",
"_name": "Sharp"
}
],
},
{
"_obj": "set",
"_target": [
{
"_ref": "layer",
"_enum": "ordinal",
"_value": "targetEnum"
}
],
"to": {
"_obj": "layer",
"name": layerName
},
}
],{
"synchronousExecution": false,
"modalBehavior": "fail"
});
}