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

Remove values after the period

Enthusiast ,
Feb 20, 2024 Feb 20, 2024

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.

 

TOPICS
Actions and scripting
731
Translate
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

Community Expert , Feb 20, 2024 Feb 20, 2024

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

Translate
Adobe
Community Expert ,
Feb 20, 2024 Feb 20, 2024

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?  :]

 

Translate
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
Enthusiast ,
Feb 20, 2024 Feb 20, 2024

no it is not a jpg extension
and the value you see on the slider.

 

Translate
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 ,
Feb 20, 2024 Feb 20, 2024

I can't see anything?

 

If you're replying via email, the web interface has to be used to insert images.

Translate
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
Enthusiast ,
Feb 20, 2024 Feb 20, 2024

Stefano, you're right, sorry
I thought I had included the image
here she is

Schermata 2024-02-20 alle 13.03.39.png

Translate
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 ,
Feb 20, 2024 Feb 20, 2024

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

Translate
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
Enthusiast ,
Feb 20, 2024 Feb 20, 2024

Stefano works wonderfully
I managed to adapt it to uxp successfully.

thank you you are a great friend.

 

Translate
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 ,
Feb 20, 2024 Feb 20, 2024

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);

 

Translate
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
Enthusiast ,
Feb 20, 2024 Feb 20, 2024

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?

 

Translate
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 ,
Feb 20, 2024 Feb 20, 2024

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

 

Translate
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
Enthusiast ,
Feb 20, 2024 Feb 20, 2024

volevo dire che voglio eliminare tutti i livelli vuoti

Schermata 2024-02-20 alle 14.13.27.png

 

Translate
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 ,
Feb 20, 2024 Feb 20, 2024
quote

I meant I want to delete all the empty layers

Schermata 2024-02-20 alle 14.13.27.png

 


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.

Translate
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
Enthusiast ,
Feb 20, 2024 Feb 20, 2024
LATEST

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

Translate
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