Sair
  • Comunidade global
    • Idioma:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Javascript to select background layer and apply solid color

Iniciante na comunidade ,
Dec 19, 2021 Dec 19, 2021

Hi i need a Javascript to select background layer and apply solid color for photoshop CC 2019. Can anyone give code for this,

Thanks in advance.

TÓPICOS
Ações e scripts
1.3K
Traduzir
Denunciar
Diretrizes da comunidade
Seja respeitoso, dê crédito à fonte original do conteúdo e verifique se há cópias antes da publicação. Saiba mais
community guidelines

correct answers 1 resposta correta

Mentor , Dec 19, 2021 Dec 19, 2021

It looks like you manually changed the name of the first layer and the auto rename is not working. Try this:

 

for (var i=2;i<=1000;i++)
{activeDocument.activeLayer.name=(activeDocument.activeLayer=activeDocument.activeLayer.duplicate()).textItem.contents=i}

 

 

 

Traduzir
Adobe
Mentor ,
Dec 19, 2021 Dec 19, 2021

1. Create text layer '1'  with properties like shadows, strokes, etc

2. Select it on layers palette

3. Run script

for (var i=2; i<=1000;i++)
{(activeDocument.activeLayer= activeDocument.activeLayer.duplicate ()).textItem.contents = i}
Traduzir
Denunciar
Diretrizes da comunidade
Seja respeitoso, dê crédito à fonte original do conteúdo e verifique se há cópias antes da publicação. Saiba mais
community guidelines
Iniciante na comunidade ,
Dec 19, 2021 Dec 19, 2021

Omg that's amazing!!! it worked! Thank you!

The only issue I found was that the layers were named:

"1 Copy 1"

"1 Copy 2"

"1 Copy 3"

etc

 

If there was a name to take the name of the text that's in that layer that would be amazing. 

Either way thank you so much you genius!!! 

Traduzir
Denunciar
Diretrizes da comunidade
Seja respeitoso, dê crédito à fonte original do conteúdo e verifique se há cópias antes da publicação. Saiba mais
community guidelines
Mentor ,
Dec 19, 2021 Dec 19, 2021

It looks like you manually changed the name of the first layer and the auto rename is not working. Try this:

 

for (var i=2;i<=1000;i++)
{activeDocument.activeLayer.name=(activeDocument.activeLayer=activeDocument.activeLayer.duplicate()).textItem.contents=i}

 

 

 

Traduzir
Denunciar
Diretrizes da comunidade
Seja respeitoso, dê crédito à fonte original do conteúdo e verifique se há cópias antes da publicação. Saiba mais
community guidelines
Iniciante na comunidade ,
Dec 19, 2021 Dec 19, 2021

I spoke too soon! that's it! PERFECT TY!!!!! ❤️

Traduzir
Denunciar
Diretrizes da comunidade
Seja respeitoso, dê crédito à fonte original do conteúdo e verifique se há cópias antes da publicação. Saiba mais
community guidelines
Iniciante na comunidade ,
Dec 19, 2021 Dec 19, 2021

Sorry I couldn't find a way to edit my message. 
I did a little bit of research here: https://graphicdesign.stackexchange.com/questions/33621/restore-photoshop-text-layer-name-auto-updat...

 

And found that when I select the text tool, click into the layer and just hit escape, it renames the layer the value of the text (if that makes sense). I wonder if there's a script that could sort of emulate this that I can use in conjunction with the last one?

Traduzir
Denunciar
Diretrizes da comunidade
Seja respeitoso, dê crédito à fonte original do conteúdo e verifique se há cópias antes da publicação. Saiba mais
community guidelines
Community Expert ,
Dec 19, 2021 Dec 19, 2021

I think yot are clicking or double clicking on the layer's name in the layers Palette to edit the layer's name. Try clicking off the name to select the layer. Do  not edit the layer name.

JJMack
Traduzir
Denunciar
Diretrizes da comunidade
Seja respeitoso, dê crédito à fonte original do conteúdo e verifique se há cópias antes da publicação. Saiba mais
community guidelines
Iniciante na comunidade ,
Dec 19, 2021 Dec 19, 2021

Great thanks JJmack!

Traduzir
Denunciar
Diretrizes da comunidade
Seja respeitoso, dê crédito à fonte original do conteúdo e verifique se há cópias antes da publicação. Saiba mais
community guidelines
Community Expert ,
Dec 19, 2021 Dec 19, 2021

@Geekygreek22317303i6i4 wrote:

Sorry I couldn't find a way to edit my message. 
I did a little bit of research here: https://graphicdesign.stackexchange.com/questions/33621/restore-photoshop-text-layer-name-auto-updat...

 

And found that when I select the text tool, click into the layer and just hit escape, it renames the layer the value of the text (if that makes sense). I wonder if there's a script that could sort of emulate this that I can use in conjunction with the last one?


 

I can't reproduce that and I am not following the problem or request, can you post a screenshot?

 

Via scripting, text layers can have both a name (.name), and contents (.contents) – which may or may not be "coupled" or even the same.

 

If this is simply about renaming many existing layers:

 

https://github.com/Paul-Riggott/PS-Scripts/blob/master/Layer%20Name%20Edit.jsx

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

EDIT: The script posted by jazz-y retains the automated "link" between the text layer content and the text layer name, so if the content is changed the layer name is automatically changed to match. Once the layer name is manually edited, it is no longer "coupled" to the content and will not automatically update with content changes. 

Traduzir
Denunciar
Diretrizes da comunidade
Seja respeitoso, dê crédito à fonte original do conteúdo e verifique se há cópias antes da publicação. Saiba mais
community guidelines
Iniciante na comunidade ,
Dec 19, 2021 Dec 19, 2021

Sorry that message I posted was after Jazzy figured out the solution for me. I'm all set now, worked perfectly!

Also something I gotta remember going forward, as a couple of you mentioned; I was editing the layer name and not the layer so it caused some of the issues  

Traduzir
Denunciar
Diretrizes da comunidade
Seja respeitoso, dê crédito à fonte original do conteúdo e verifique se há cópias antes da publicação. Saiba mais
community guidelines
Community Expert ,
Dec 20, 2021 Dec 20, 2021

Ah OK then, case closed! Please mark the post/s from jazz-y as the correct answer/s then, thanks.

Traduzir
Denunciar
Diretrizes da comunidade
Seja respeitoso, dê crédito à fonte original do conteúdo e verifique se há cópias antes da publicação. Saiba mais
community guidelines
Iniciante na comunidade ,
Dec 20, 2021 Dec 20, 2021

Done, thanks so much!

Traduzir
Denunciar
Diretrizes da comunidade
Seja respeitoso, dê crédito à fonte original do conteúdo e verifique se há cópias antes da publicação. Saiba mais
community guidelines
LENDA ,
Dec 21, 2021 Dec 21, 2021
MAIS RECENTE

 

sTT = stringIDToTypeID, cntr = 999; while(cntr)
	(dsc2 = new ActionDescriptor()).putString(sTT('name'), 1000 - --cntr),
	(dsc1 = new ActionDescriptor()).putObject(sTT('new'), sTT('layer'), dsc2),
	dsc1.putBoolean(sTT('copy'), true), executeAction(sTT('make'), dsc1)

 

Traduzir
Denunciar
Diretrizes da comunidade
Seja respeitoso, dê crédito à fonte original do conteúdo e verifique se há cópias antes da publicação. Saiba mais
community guidelines