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

Placing textframes at specific coordinates relative to page

Explorer ,
Oct 07, 2015 Oct 07, 2015

Copy link to clipboard

Copied

Hi!

I'm after a script or some other solution to automatically move text frames to specific X/Y-coordinates on a page. I know this is possible with text anchors, but in my case there is no text to anchor the frame too. It's only one text frame on the page and I want it to snap to a specific place on every page by running a script or applying a object style. It's a million pages, so doing it manually is a very time consuming procedure.

Rune

TOPICS
Scripting

Views

1.4K

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

Engaged , Oct 08, 2015 Oct 08, 2015

While Equalizer is definitely worth a loook, for the time being you could try this:

app.doScript (main, undefined, undefined, UndoModes.ENTIRE_SCRIPT, "Move Textframes")

function main() {
     app.findTextPreferences = NothingEnum.NOTHING;
     app.findTextPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyles.item("dings");
     var hits = app.activeDocument.findText();
     for (var n = 0; n < hits.length; n++) {
          var tf = hits.parentTextFrames;
          if (tf.length
...

Votes

Translate

Translate
Community Expert ,
Oct 07, 2015 Oct 07, 2015

Copy link to clipboard

Copied

Are these existing pages with content, or pages that will be newly created?

If they are newly created pages, you could build one page with the text box in the correct place, and then duplicate that page the required number of times.

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
Explorer ,
Oct 07, 2015 Oct 07, 2015

Copy link to clipboard

Copied

Hi!

These are random pages which is already created. The pages contain different objects already, including the text frame I want to reposition. I do have to do some manual work here, but if I can apply a object style that will re-format the text and text frame AND move it into the correct location on the page with just a click or two, it will save me a lot of time.

Rune

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 ,
Oct 07, 2015 Oct 07, 2015

Copy link to clipboard

Copied

I've moved this over to the scripting forum. Mu instinct is this is going to be a relatively easy thing to script -- select the frame and then the script can apply a predefined object style and predefined set of coordinates, and you could apply a keyboard shortcut to the script.

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 ,
Oct 07, 2015 Oct 07, 2015

Copy link to clipboard

Copied

How can you tell on a page which is the text frame you want to move? Is there anything that distinguishes those frames from other frames on a page?

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
Explorer ,
Oct 07, 2015 Oct 07, 2015

Copy link to clipboard

Copied

I have to manually apply the script to the frame. My plan/hope is to do a search for the para-style used on the text in the frame and then apply the keyboard shortcut, as Peter described, to the frame.

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 ,
Oct 07, 2015 Oct 07, 2015

Copy link to clipboard

Copied

Peter Kahrel is totally right! … And I don't really understand! If you research is based on a para style, a simple regex is enough!

Screenshots could help us to understand!

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 ,
Oct 07, 2015 Oct 07, 2015

Copy link to clipboard

Copied

Well, Obi, regex won't come into play here I don't think.

Runee: what about the following: look for all instances of a certain paragraph style, then move the frame in which an instance occurs to the defined position. No need to press any keys (apart from the one to run the script:))

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
Engaged ,
Oct 07, 2015 Oct 07, 2015

Copy link to clipboard

Copied

Try

// BOTTOM_CENTER_ANCHOR, BOTTOM_LEFT_ANCHOR, BOTTOM_RIGHT_ANCHOR
// CENTER_ANCHOR, LEFT_CENTER_ANCHOR, RIGHT_CENTER_ANCHOR
// TOP_CENTER_ANCHOR, TOP_RIGHT_ANCHOR
if (app.selection.length > 0) {
     app.activeDocument.layoutWindows[0].transformReferencePoint = AnchorPoint.TOP_LEFT_ANCHOR;

     app.selection[0].move( [20, 40] );
}

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
Explorer ,
Oct 08, 2015 Oct 08, 2015

Copy link to clipboard

Copied

Hi guys.

Thanks for all your suggestions. I have to admit I'm having trouble understanding exactly what to do. I'm a fairly experienced ID user, but I haven't used custom scripts before. Is there some way to define where on the page the frame should go in the script posted by G.Singelmann? And is this a script that will be a part of pkahrel's idea?


Any further explanation will be most welcome!:)


Rune

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 ,
Oct 08, 2015 Oct 08, 2015

Copy link to clipboard

Copied

Gerald's (that's G. Singelmann) script assumes you select a text frame and run the script to move the frame (you would assign the script to a shortcut key). In the example, the frame is moved to 20 units from the left side of the page and 40 units from the top (assuming that the rulers are set to 'Ruler per page'). The units are the units (mm, pts, etc.) of the document.

What I suggested was a script that moves all eligible frames to a certain position on the page. That of course depends on whether you can define 'eligible' narrow enough so that all and only those frames can be found, e.g. by a paragraph style, as you mentioned.

Peter

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
Explorer ,
Oct 08, 2015 Oct 08, 2015

Copy link to clipboard

Copied

Thank's again.

I've tried the script and it works perfect. (Thank you Gerald!)

Now, another "problem" has occurred. When I do a search for a para-style, of course the text inside the frame gets highlighted, not the frame itself. Is there a way to search for a frame containing text, tagged with a para-style?

Sorry if my english is a bit sloppy. Not my native language...

Rune

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 ,
Oct 08, 2015 Oct 08, 2015

Copy link to clipboard

Copied

Press Esc.

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
Engaged ,
Oct 08, 2015 Oct 08, 2015

Copy link to clipboard

Copied

While Equalizer is definitely worth a loook, for the time being you could try this:

app.doScript (main, undefined, undefined, UndoModes.ENTIRE_SCRIPT, "Move Textframes")

function main() {
     app.findTextPreferences = NothingEnum.NOTHING;
     app.findTextPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyles.item("dings");
     var hits = app.activeDocument.findText();
     for (var n = 0; n < hits.length; n++) {
          var tf = hits.parentTextFrames;
          if (tf.length > 0) {
               tf = tf[0];
               tf.move( [0,0] );
          }
     }
}

Replace "dings" with the name of your paragraph style. Replace "[0,0] " with your coordinates

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
Guru ,
Oct 08, 2015 Oct 08, 2015

Copy link to clipboard

Copied

Hi Gerald,

I didn't read to much of this thread but it's probably a good practice in these types of cases to use a cache so as not to call unnecessary multiple "moves" to a text frame that contains multiple "dings"  paragraph styles

Trevor

function main() {

     app.findTextPreferences = NothingEnum.NOTHING;

     app.findTextPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyles.item("dings");

     var cache = {};

     var hits = app.activeDocument.findText();

     for (var n = 0; n < hits.length; n++) {

          var tf = hits.parentTextFrames;

          if (tf.length > 0) {

               tf = tf[0];

               if (tf.id in cache) continue;

               tf.move( [0,0] );

               cache[tf.id] = true;

          }

     }

}

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
Engaged ,
Oct 08, 2015 Oct 08, 2015

Copy link to clipboard

Copied

Hi Trevor,

I guess there are at least a dozen ways to improve that little snippet. Yours is a very sensible one, thanks

Gerald

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
Explorer ,
Oct 09, 2015 Oct 09, 2015

Copy link to clipboard

Copied

LATEST

Awesome!

Thank's guys!

Rune

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
Guide ,
Oct 08, 2015 Oct 08, 2015

Copy link to clipboard

Copied

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