Copy link to clipboard
Copied
Continue my project
I ran into this problem
I would like to delete the values after the dot,
Is there something to do this?
rightly the code will be adapted to uxp.
OK, it would depend on the goal, one way is to parse the floating number as an integer:
var theValue = 52.51282051;
var theNewValue = parseInt(theValue);
alert(theValue + "\n" + theNewValue);
https://www.w3schools.com/jsref/jsref_parseint.asp
But you could have other goals, such as rounding up or down to the nearest integer?
EDIT:
The Math.abs() Method
The Math.ceil() Method
The Math.floor() Method
The Math.round() Method
The Math.fround() Method
The Math.trunc() Method
Copy link to clipboard
Copied
Do you mean to remove a filename extension such as from myFile.jpg to myFile – or do you mean something else?
Can you please provide a clear before and after example? Some code snippet? Something? Anything? :]
Copy link to clipboard
Copied
no it is not a jpg extension
and the value you see on the slider.
Copy link to clipboard
Copied
I can't see anything?
If you're replying via email, the web interface has to be used to insert images.
Copy link to clipboard
Copied
Stefano, you're right, sorry
I thought I had included the image
here she is
Copy link to clipboard
Copied
OK, it would depend on the goal, one way is to parse the floating number as an integer:
var theValue = 52.51282051;
var theNewValue = parseInt(theValue);
alert(theValue + "\n" + theNewValue);
https://www.w3schools.com/jsref/jsref_parseint.asp
But you could have other goals, such as rounding up or down to the nearest integer?
EDIT:
The Math.abs() Method
The Math.ceil() Method
The Math.floor() Method
The Math.round() Method
The Math.fround() Method
The Math.trunc() Method
Copy link to clipboard
Copied
Stefano works wonderfully
I managed to adapt it to uxp successfully.
thank you you are a great friend.
Copy link to clipboard
Copied
You're welcome. Sorry, it takes me longer to think in UXP:
let theValue = 52.51282051;
let theNewValue = parseInt(theValue);
require('photoshop').core.showAlert(theValue + "\n" + theNewValue);
Copy link to clipboard
Copied
Stephen I totally understand your point
but my process is more complex than the example below,
I just need to understand the mechanism, then I sit down and think about how I can adapt it to my needs.
you always help me solve my queries.
Now I find myself with a big problem
with uxp I can't delete empty layers
do you have any idea?
Copy link to clipboard
Copied
Really? It is a work in progress and you are an "early adopter" on the bleeding edge! :]
I presume that you mean that there is no DOM option.
But that is why there is batchPlay, it's verbose, it could possibly be shortened from the raw form:
async function actionCommands() {
let command;
let result;
let psAction = require("photoshop").action;
// Delete current layer
command = {"_obj":"delete","_target":[{"_enum":"ordinal","_ref":"layer","_value":"targetEnum"}],"layerID":[2]};
result = await psAction.batchPlay([command], {});
}
async function runModalFunction() {
await require("photoshop").core.executeAsModal(actionCommands, {"commandName": "Action Commands"});
}
await runModalFunction();
EDIT: I did find this DOM reference, but it will take more work to make it usable!
https://developer.adobe.com/photoshop/uxp/2022/ps_reference/classes/layer/#delete
Copy link to clipboard
Copied
volevo dire che voglio eliminare tutti i livelli vuoti
Copy link to clipboard
Copied
I meant I want to delete all the empty layers
By @Ciccillotto
Ah, good luck with that! :]
Knowing how to do this with .jsx isn't probably going to help with any UXP specifics, apart from the general overall approach. For all I know UXP may offer a more elegant way of doing this than legacy scripts.
Copy link to clipboard
Copied
Unfortunately I looked at the uxp documentation and couldn't find anything about it, I saw the jsx file that does this, but it's not easy to convert it to uxp. it means I have to give up. thanks again for your help
Find more inspiration, events, and resources on the new Adobe Community
Explore Now