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

Adressing an object by it's id

Community Beginner ,
Apr 25, 2012 Apr 25, 2012

Copy link to clipboard

Copied

I'm failing to write a line that will adress a textframe by id (which is 3771) and then move it.

This is how my attempt looks:

app.activeDocument.textFrames.item.id(3771).move([0, 0, 7, 2]);

Any help is appreciated

TOPICS
Scripting

Views

1.1K

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

LEGEND , Apr 25, 2012 Apr 25, 2012

It this JavaScript?

You should use app.activeDocument.textFrames.itemByID(3771).

Where did you find this .item.id() syntax?

Votes

Translate

Translate
LEGEND ,
Apr 25, 2012 Apr 25, 2012

Copy link to clipboard

Copied

It this JavaScript?

You should use app.activeDocument.textFrames.itemByID(3771).

Where did you find this .item.id() syntax?

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 Beginner ,
Apr 25, 2012 Apr 25, 2012

Copy link to clipboard

Copied

Hi John, and thanks

Consider me an absolute noob. Yes this is JavaScript. I found fragments within another script which I thought would work, but didn't. With your correction, and some further research it now looks like this:

var textblock = app.activeDocument.textFrames.itemByID(3771);

textblock .move( [0, 4] );

but still doesn't move the textframe.

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
LEGEND ,
Apr 25, 2012 Apr 25, 2012

Copy link to clipboard

Copied

Your answer to "where?" is "somewhere" but not-gonna-say? I see.

Are you sure your ID is correct? What if you use

var textblock = app.activeDocument.textFrames[0];

? Are your units set reasonably so that you would see a [0,4] move?

Do you get an error?

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 Beginner ,
Apr 26, 2012 Apr 26, 2012

Copy link to clipboard

Copied

Didn't think it was relevant, but here you go (an instance of "textFrame.id", from InDesignCS5_ScriptingGuide_JS.pdf)


http://dl.dropbox.com/u/5420164/Screen%20shot%202012-04-26%20at%2016.11.00.png

The id was wrong, just like you said.

This line now works:

app.activeDocument.textFrames.itemByID(3768).move( [0, 4] );

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
LEGEND ,
Apr 26, 2012 Apr 26, 2012

Copy link to clipboard

Copied

LATEST

Note that you can in fact use inline images here...

Screen shot 2012-04-26 at 16.11.00.png

Anyhow, I guess you've figured it out, but

var myID = myTextFrame.id;

merely sets myID to the ID number of the text frame. It doesn't mean that you can add parens after id() and parametrize an index through it.

Glad you got it working!

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