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

JSX - Referencing Layer(s) Syntax Question

Engaged ,
Dec 30, 2021 Dec 30, 2021

Hi everybody,

 

So I'm breaking to learning how to use the script "generator" (ScriptListener/CleanSL) and learning why errors keep coming up with common code. I'm used to working in Flash/Animate and CSS/JS errors in web pages. Sourcing errors in this environment is a little less intuitive for me so pardon the persistent questions...

 

I pulled a script from an expert, I've dumbed it down. It looks simple enough, but not knowing this environment well I'm not sure why it doesn't run.

 

var aDoc = documents.add();

var aLay1 = aDoc.layers.add();
var subLay2 = aLay1.layers.add();

 

 

The second line creates an error: Error 1302: No such element

 

Now, I pulled another code from the scripting guide and it works fine:

 

var aDoc2 = documents.add();

var aLay1 = aDoc2.artLayers.add()
textLayerRef.name = "my text"
textLayerRef.kind = LayerKind.TEXT

 

 

I don't imagine the first is a deprecated version of layer referencing as I also found this in the guide as well:

 

layers["Layer 3"].name
//using the collection name and square brackets for the collection

 

 

Layers looks pre-defined and is treated like an array object as far as I can tell, but these layers log out as 'undefined' and typeOf tells me it's not a function. So...I'm trying to figure out what's wrong form for the first set of layer building. 

 

Both try to add(), but only the latter works. Is 'artLayers' just a new school thing for 'layers'?

 

Thanks for reading. 

 

 

TOPICS
Actions and scripting
897
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 2 Correct answers

LEGEND , Dec 30, 2021 Dec 30, 2021
documents.add().layerSets.add().artLayers.add()

activeDocument.layers['Group 1'].name
Translate
Community Expert , Dec 30, 2021 Dec 30, 2021

It all about Adobe's Photoshop  Object Model

image.pngexpand image

A Photoshop Document has a Layer Set.  In the Layer Set you can have other Layer Sets and Art Layers.  To Process the whole document you need to Process the Document's Layer Set recursively for there can be nested Layer Sets. Its About Adobe Photoshop Objects and Object's Properties and Methods  

 

Doc.layers.add() is invalid there is no Method .add() for the Photoshop DOM Layers collection  the Array contains objects that are Layers and LayerSets.

image.pngexpand image

...
Translate
Adobe
Community Expert ,
Dec 30, 2021 Dec 30, 2021
.layers.add();

vs

.artLayers.add()

 

image.pngexpand imageimage.pngexpand image

JJMack
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
LEGEND ,
Dec 30, 2021 Dec 30, 2021
documents.add().layerSets.add().artLayers.add()

activeDocument.layers['Group 1'].name
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 ,
Dec 30, 2021 Dec 30, 2021

It all about Adobe's Photoshop  Object Model

image.pngexpand image

A Photoshop Document has a Layer Set.  In the Layer Set you can have other Layer Sets and Art Layers.  To Process the whole document you need to Process the Document's Layer Set recursively for there can be nested Layer Sets. Its About Adobe Photoshop Objects and Object's Properties and Methods  

 

Doc.layers.add() is invalid there is no Method .add() for the Photoshop DOM Layers collection  the Array contains objects that are Layers and LayerSets.

image.pngexpand image

 Layers objects are artLayers and Doc.artLayers.add() is a valid method

image.pngexpand image

image.pngexpand image

image.pngexpand image

 

JJMack
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
Engaged ,
Dec 31, 2021 Dec 31, 2021

Ahhhh, I see. Okay, I get it. Layers encompasses artLayers which are generally used for imagery purposes. But Layers (Layer Sets) themselves references the total gamut of 'layers' within a composition.

 

That, and their method set is a parent up from artLayers and don't reflect the attributes of artLayers.

 

Excellent, thank you so much guys!

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
LEGEND ,
Dec 31, 2021 Dec 31, 2021

Mark correct solution(s) if you see any 😉

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
Engaged ,
Jan 01, 2022 Jan 01, 2022

Sorry, getting used to that part, will do! Thanks!

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
Engaged ,
Jan 01, 2022 Jan 01, 2022

So in essence, creating a LayerSet object is kind of like creating a Layers panel (without all the gizmos), right?

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
Engaged ,
Jan 01, 2022 Jan 01, 2022

Actually, I take that back. A layerSet =  group.

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
LEGEND ,
Jan 01, 2022 Jan 01, 2022
LATEST

They are containers for regular layers, like folders for files.

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