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

In a frame group, how do I get the layerID array?

Participant ,
Dec 18, 2022 Dec 18, 2022

Copy link to clipboard

Copied

In a frame group --

Screenshot 2022-12-18 at 13.17.24.png

How do I get the LayerID array? eg [5, 52]

and is it always ordered right to left?

 

Code below from Alchemist, selecting the layer...

   {
      _obj: "select",
      _target: [
         {
            _ref: "layer",
            _name: "Layer 0 Frame"
         }
      ],
      makeVisible: false,
      layerID: [
         5,
         52
      ],
      _options: {
         dialogOptions: "dontDisplay"
      }
   }

 

var lays = app.activeDocument.layers
lays[0].id only gives me the first LayerID.
 
TIA
TOPICS
Actions and scripting

Views

176

Likes

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

correct answers 1 Correct answer

Community Expert , Dec 18, 2022 Dec 18, 2022

As far as I understand a framedGroup is not a Group, so it is one Layer and should therefore only have one layerID. 

 

What is the actual problem? 

Likes

Translate

Translate
Community Expert ,
Dec 18, 2022 Dec 18, 2022

Copy link to clipboard

Copied

As far as I understand a framedGroup is not a Group, so it is one Layer and should therefore only have one layerID. 

 

What is the actual problem? 

Likes

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
Participant ,
Dec 18, 2022 Dec 18, 2022

Copy link to clipboard

Copied

I want to move an image to the frame (layer-ha). Is there a better method, without getting/ knowing the missing ID's [eg. 5,52]?

Alchemist knows the ID so it must be acessible. But I don't know how...

 

Screenshot 2022-12-18 at 14.28.52.png

Likes

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 ,
Dec 18, 2022 Dec 18, 2022

Copy link to clipboard

Copied

Please provide a meaningful description of the process you are trying to automate. 

How are the Frame and the Smart Object defined to begin with? 

Are they the only Frame and the only Smart Object in the document? 

Likes

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
Participant ,
Dec 18, 2022 Dec 18, 2022

Copy link to clipboard

Copied

Creating a frame on an image has TWO DIFFERENT BEHAVIORS.

1. A frame is created on the image layer, or...

2. A frame is created above the image layer.

This is dependant on the size of the frame size in relation to the image.

To see what I mean, try the following.

---------------------------

SETUP;

Open an image file.

Create a background layer filled with white.

Turn on gridlines every 33.3333 percent, 1 subdivision. Show gridlines.

Select the image layer and with the frame tool, drag a frame inside the center square gridline. 

     === A frame layer is created above the image layer.

UNDO, Now try;

Select the image layer and with the frame tool, drag a frame larger than the center square gridline.

     === A frame layer is created on the image layer.

 

I came across the problem that when I resized the smart object to 50% of the original size. It is impossible to create a frame larger than 33.3333% height of the of the orignal size, even if I select the whole image. I would have to first change the smart object to a layer, crop and delete pixel data before the frame tool took into account the new size. 

With this understanding, I think it easier to simply check if a new frame layer is created, move the image to the newly created frame layer, which I've started doing here...

 

document
  .getElementById("btnMoveImageToFrameLayer")
  .addEventListener("click", async function () {
    var lays1 = app.activeDocument.layers;
FrameLayerINDEX = lays.length;
ImageLayerID = lays[lays.length-3].id;
IamgeName = lays[lays.length-3].name;
console.log(`FrameLayerINDEX: ${FrameLayerINDEX}`);
console.log(`ImageLayerID:  ${ImageLayerID}`);
console.log(`IamgeName:  ${IamgeName}`);

//Add a check if number of layers increases, a frame layer was created, so move image to frame layer.

    actions=[
      {
        _obj: "move",
        _target: [
           {
              _ref: "layer",
              _name: IamgeName
           }
        ],
        to: {
           _ref: "layer",
           _index: FrameLayerINDEX
        },
        adjustment: false,
        version: ImageLayerID,
        layerID: [
          ImageLayerID
        ],
        _options: {
           dialogOptions: "dontDisplay"
        }
     }
  
   ];
      core.executeAsModal(async () => {batchPlay(
        [...actions],{});
    });
    });
  

 

 

 

Likes

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 ,
Dec 18, 2022 Dec 18, 2022

Copy link to clipboard

Copied

I guess I don’t understand your process. 

Why use frames at all and not the Rectangle Tool and Ellipse Tool to create Vector Masks if you want to apply them to existing Smart Objects? 

Frames would, in my opinion, primarily make sense for a template that one populates with placed images after setting up the frames. 

Likes

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
Participant ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

my intent is a dynamic template.

I didn't see any difference in choosing a vector or frame - results are the same. I don't have a pros cons between vector or frame so I just picked one. Maybe the way I referenced the image, but the rect tool +mask seemes to take more calcs/ steps concerning a resized smart object to accomplish the same thing as the frame tool. 

Likes

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 ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

Just to make sure:

I was not talking about »mask«, but »Vector Masks«. 

So the plural »more calcs/ steps« would seem exaggerated for individual application (not for multiple uses, naturally); creating the Path should be no more work that the Frame and applying the Vector Mask takes one cmd-click. 

Likes

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
Participant ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

Yes, I see your point with the vector mask. I want the best interface for the user so I will change. Bonus is that changing from frame to vector will be getting rid of the yellow "frame" 😜
Anyway, I now know more about frame's quirky behavior and why it sometimes puts the frame on a new layer -- and I definitely want/need frames in my next product.

Likes

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 ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

LATEST

If you want to distribute templates to other users frames might be the better choice indeed. 

Likes

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
Participant ,
Dec 18, 2022 Dec 18, 2022

Copy link to clipboard

Copied

Frame LAYER, oh I see now. The ID of the image on the frame layer doesn't exist initially. Once you move the image to the frame layer, the image ID is transferred to the frame Layer.

 

I moved the image to the frame layer and didn't notice it was the same ID.

Likes

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