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

Control adding photoshop layers with script?

New Here ,
Sep 13, 2020 Sep 13, 2020

Copy link to clipboard

Copied

I don't know exactly why the other post is hidden but adobe's tech support is getting tired of dealing with people abusing their mark spam system and is working on ways to fix that.

 

I'm trying to make a jsx script that allows me to add up to 20 layers at a time and any number of layers in between 0 and 20 and also take them away if I decrease the number before closing the script. I noticed that in Photoshop one is required to use the dialog class which could be part of the problem:

 

var myPanel = new Window("dialog","Slider Control",undefined,{resizeable: true});
var sliderText = myPanel.add("statictext",undefined,undefined);
var slider = myPanel.add ("slider", undefined, 0, 0, 20);
var buttonExit = myPanel.add("button",undefined,"Close Dialog Box");
slider.size = [80, 20]
sliderText.text = "Layers";
k = Math.round(slider.value);
newArray =[]
slider.onChange = function (){
    for (i=0; i<k; ++i){
        newArray.push(activeDocument.activeItem.layers.add);
}
}

 

This script should generate a window and slider but does not seem to add new layers. If there is an error in the code that prevents the window from loading, let me know and I will try to fix it. Any help would be appreciated!

TOPICS
Actions and scripting

Views

1.8K

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
New Here ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

Dude, the fact that it's junk is exactly why I asked on how to fix it. I don't need help with the show command nor the slider being 0, I didn't ask about those, I asked about getting the slider to properly interpret the for-loop values. You do not understand how professional support works. Changing it to activeDocument doesn't solve it because it also fails for other types of objects. It could be a fragment of a possible solution, but it alone is not at all a solution.

Votes

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 Expert ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

Paul use to help here. He was perhaps the best scripter that ever participated here. I post his sample script for a script with  working slider in its dialog. For one to user to set a value and when the were satisfied they could use a run button for the script to execute the function the slider was set for then after  the function was performed the script would terminate. The was also a cancel button in case the user changed their mind and did not want to execute the function. 

 

You never detailed how you want  you script to function there was no code to display the dialog.  or to terminate the script, no code for the dialog's exit button.   There is no code to add a layer.  No test to see if the is an active document.  Perhaps scripting is too much for you. You ask questions but do not seem the understand  the replies you receive.  Because we are unprofessional user with no communication skill. You the judge the that does not want to communicate.  You have received no good advice. Some have tried. I know I do not have the best communication skills but over the years I have help many users. You are an exception I'll note that down.  Good night  it past my bed time.

JJMack

Votes

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
New Here ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

LATEST

You keep saying "we" as a way to use your coworkers as a human shield to mask your own incompitence.

 

My problem isn't with Adobe, it's with you; *you* lack the communication skills and technical skills to be qualified in handling this question. You admitted you didn't know javascript and Adobe's extended script and you admitted that r-bin was the one secretly doing your job for you in the instances you got credit for scripting solutions and even yet again you now claim you took another person's code. You couldn't explain Paul's code after I brought up that problem because you don't understand it yourself. You don't unerstand it yourself because you are not qualified to handle this question.You have no basis whatsoever to tell anyone whether they can handle any kind of scripting, anything more is nothing less than the epitome of hypocricy.

 

Pual's script as you claim it is, did not work for me. It has an error on line 56. Since my scripting is "junk," I can't do much more than point that out to you, but you refused to listen.

 

I was assured by Adobe's customer support that the person who answers this question will be an expert of the required expertise. An expert wouldn't have trouble adding "myPanel.show();" nor would they have trouble adding

"if (myWindow !== null && myWindow instanceof Window)
{

myWindow.center();
myWindow.show();
}"

or an equivalent statement. Since those codes work for me, I have no questions about them, the main issue is the structure of the for-loop itself for which several variables and conditions need to be defined. As I repeatedly said, using "app.activeDocument.artLayers.add();" does not fix the loop-to-slider issue, but you refused to listen over and over and over and over and over.

 

 

 

 

Votes

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