Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Retrieve number of the column of searched text

Enthusiast ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

Hi,

I am looking for how, with a GREP search, to retrieve the number of the column of the searched text, when this one is in a multi-column text frame.

_Sans_titre-2___43___Aperçu_GPU_.png

Thanks for your help. 

Ronald

TOPICS
Scripting

Views

452

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 2 Correct answers

Adobe Community Professional , May 24, 2021 May 24, 2021
It's not possible with GREP to know anything about columns, unfortunately. It is possible (but not easy) with scripting. (Not easy when span and split column is being used.)

Likes

Translate

Translate
Adobe Community Professional , May 24, 2021 May 24, 2021
You could try this: var s = app.documents.item(0).selection[0]; var ho = s.horizontalOffset; var cc = s.parentTextFrames[0].textFramePreferences.textColumnCount; var cw = s.parentTextFrames[0].textFramePreferences.textColumnFixedWidth; var g = s.parentTextFrames[0].textFramePreferences.textColumnGutter; var x = s.parentTextFrames[0].geometricBounds[1] for (var i = 0; i < cc; i++){ var cx = i*(cw+g) + x; if (ho >= cx && ho < cx + cw) { alert("Selected text starts in column " +...

Likes

Translate

Translate
Adobe Community Professional ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

It's not possible with GREP to know anything about columns, unfortunately.

It is possible (but not easy) with scripting. (Not easy when span and split column is being used.)

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
Enthusiast ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

Hi,

That's what I thought, but maybe someone had the quick fix 🙂

When you say "It is possible (but not easy) with scripting", can you tell me more? I looked at the properties of textframe, story and insersionpoint and couldn't find anything.

Regards

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
Adobe Community Professional ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

You could try this:

 

var s = app.documents.item(0).selection[0];
var ho = s.horizontalOffset;
var cc = s.parentTextFrames[0].textFramePreferences.textColumnCount;
var cw = s.parentTextFrames[0].textFramePreferences.textColumnFixedWidth;
var g = s.parentTextFrames[0].textFramePreferences.textColumnGutter;
var x = s.parentTextFrames[0].geometricBounds[1]


for (var i = 0; i < cc; i++){
    var cx = i*(cw+g) + x;
    if (ho >= cx && ho < cx + cw) {
        alert("Selected text starts in column " + (i+1))
    } 
};   

 

 

Screen Shot 19.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
Enthusiast ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

Cool, merci pour l'aide 😉

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
Adobe Community Professional ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

@rob That's very good. I think I normally use the index property of a textColumn which gives the index of the first character in the column, and then check for that, because relying on horizontal offset is perhaps less reliable for non-rectangular frames.

With span and split columns it gets a lot more complicated though, because (for some reason) each split is considered a separate column.

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
Adobe Community Professional ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

You can do this with a single line:

// With an insertion point 'insPoint'

columnIndex = insPoint.parentStory.insertionPoints.itemByRange (insPoint.parentTextFrames[0].insertionPoints[0].index, insPoint.index).textColumns.length;

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
Adobe Community Professional ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

Thanks Peter, that’s much better.

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
Adobe Community Professional ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

This is master stroke.

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
Advisor ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

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
Advisor ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

But not really convinced by the answers given!

 

It seems to me the matter is more about a geographic localization!

That remembers me about a script of mine written in 2011 and this function "InsertCoordinateMultiPageRefs()" that added "tl" for "top-left", "tr" for "top-right", "bl" for "bottom-left", "br" for "bottom-right" after each "index entry page number", basing on the index entry marker insertion point "horizontalOffset/baseline" values!

 

Funny!

 

(^/)  The Jedi

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
Adobe Community Professional ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

Peter’s one liner is working with my selected text example:

 

var insPoint = app.documents.item(0).selection[0].insertionPoints[0];
var columnIndex = insPoint.parentStory.insertionPoints.itemByRange (insPoint.parentTextFrames[0].insertionPoints[0].index, insPoint.index).textColumns.length;
alert("Selected text starts in column " + columnIndex);

 

Screen Shot 32.png

 

Also works with a split column:

 

Screen Shot 34.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
Advisor ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

LATEST

Aha! In this second case, I would say more: "Damn it! It doesn't work!!! …"

 

… if I'm only interested by the main parent columns, not the children ones!

 

(^/)

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