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

Error when trying to select two text frames from a layer with script (Error number: 53762)

New Here ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

I am trying to create a script to select two text frames from a layer of a document so that I can copy them to another document. I managed to copy them one at a time, but I need to copy both at once because they are linked by a thread.

When I try to use the code below, I get the following error: "Error number: 53762 / Action is not enabled."

 

var layerName = "Nomes";
var sourceLayer = sourceDoc.layers.itemByName(layerName);
sourceDoc.activeLayer = sourceLayer;
var actionID = 18455;
app.menuActions.itemByID(actionID).invoke();

 

Action 18455 tries to select all items in the layer. I tried adding an action to open the layers menu before selecting them, but it made the software crash.

TOPICS
Bug , Scripting

Views

543

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

Maybe your document is corrupted - try IDMLing - export as IDML, open, save with a new name - do not overwrite your original file.

 

You can't select objects on multiple spreads - only same page / spread.

 

If you can copy one-by-one - this means that neither layer or those objects are locked? 

 

What is the exact name of the action you are trying to invoke? 

 

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

Hey, Robert!
It is a very simple document, with only one page, just for testing.
I'm trying to invoke 'Select Layer Items'.
Both textframes are on the same page, and they are not locked.

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

Which layer is active? 

 

Can you post some screenshot(s)? 

 

With edges visible and Layers pallet.

 

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

The layer 'Nomes' is active, I forgot to say that.

Sure, here are the screenshots:

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

If your Layer is "active" / selected on the Layers Panel:

RobertatIDTasker_0-1720212342934.png

 

the menu is inactive.

 

But if you select ITEM on the Layers Pallet:

RobertatIDTasker_2-1720212488626.png

 

then the menu option IS ACTIVE.

 

 

But this menu option doesn't work the way you are hoping for - it's for a situations when you select item ON the Layers pallet - and want this item to be selected IN the InDesign - it won't select all items on this Layer - in your document.

 

I've "selected" item on the Layers panel - but it isn't selected in the InDesign:

RobertatIDTasker_0-1720212678220.png

- and when I select this option - it will get selected.

 

But then "focus" switches to the parent Layer - and this menu option becomes inactive again:

RobertatIDTasker_1-1720212800213.png

 

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

Do you need to copy those TFs - in their currennt state - or do you need to just copy text contents?

 

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

I just need the text contents. I thought this way would be easier. Another alternative would be to copy the text, create frames of the same size in the other document, and paste it. But then I need to figure out a way to create threads between the two frames using the script. Im really noob in scripting, chatgpt and indesignjs.de are helping me out

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

So you need just text contents or size and relative location of the TFs as well?

 

In order to select those TFs - you would have to first get parentStory of the TF, then iterate though textContainers collection of this Story and use select method - and add each of the containers to the selection:

RobertatIDTasker_0-1720213935535.png

 

Unfortunately, I'm on my phone right now so can't give you working code.

 

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

Hi @Breno25791737ot2o, this is a conventional approach, I think. Does it help in your case?

- Mark

function main() {

    var sourceDoc = app.activeDocument;
    var layerName = "Nomes";
    var sourceLayer = sourceDoc.layers.itemByName(layerName);

    if (!sourceLayer.isValid)
        return alert('No Layer called "' + layerName + '".');

    sourceLayer.locked = false;
    sourceLayer.visible = true;

    sourceDoc.selection = sourceLayer.textFrames;

};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Your Script Name');

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

@m1b

 

It's not about selecting ALL TextFrames on a layer - but only ones that belong to a specified Story - and are on active page / spread.

 

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

Oh, sorry if I misunderstood.

 

@Breno25791737ot2o a good approach would be to post your sample document *before* the script and also the sample document *after* running the script. That way we can see exactly what you are wanting.

- Mark

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 ,
Jul 07, 2024 Jul 07, 2024

Copy link to clipboard

Copied

Mark's point was (I think) that you shouldn't try to select those frames and go through menu actions, but refeerence those frames directly.

 

To copy the frames on the Nomes layer to another document, use this:

app.documents[0].layers.item('Nomes')
  .textFrames
  .everyItem()
  .duplicate (app.documents[1].pages[0]);

This assumes your one-page document. To copy the frames on a given page, collect the frames on that page on that layer and duplicate those. Placing them on a particular layer in the target document requires an additional step.

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 ,
Jul 07, 2024 Jul 07, 2024

Copy link to clipboard

Copied

LATEST

Forgot to mention that the copied frames will be unthreaded, you'll have to re-thread them after duplicating them. (Turns out that when you copy and paste them, the frames remain threaded. But that works only on a single page/spread.)

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