Skip to main content
Phil 815
Inspiring
April 19, 2023
Answered

How to get coordinates of table column or cell

  • April 19, 2023
  • 4 replies
  • 4775 views

Hi, I've been searching for a way to get the coordinates of a table column or cell. The reason I need this data is that I want to place another object inline with a specific column/cell. I've seen some forums discussing the idea of using createOutlines() to tempoarily create an outline that I can use for it's geometricBounds property, but that doesn't seem to work (The exception I get is "NoPathCreated"). Any idea on how I could get this data would be appreciated!

This topic has been closed for replies.
Correct answer m1b

Hi @Phil 815, I've written a script that includes a function getCellBounds. See this thread for the script. To get the bounds of a column (assuming that bounds of a cell wouldn't be adequate), you could calculate it similarly to the way getTableBounds function works. Let me know how you go.

- Mark

4 replies

Community Expert
June 9, 2023

@Marc Autret said: "[Of course there is no hope that Adobe cares about this bug and tries to fix it. They focus on serious things: renaming masterpage to parentpage, etc]"

 

Hi Marc,

just voted to fix the bug at InDesign UserVoice:

 

Moving Anchoring Text to Anchored Object Crashes InDesign
Marc Autret, June 08, 2023
https://indesign.uservoice.com/forums/913162-adobe-indesign-sdk-scripting-bugs-and-features/suggestions/46753123-moving-anchoring-text-to-anchored-object-crashes-i

 

Posted code there:

 

Code:
// Tested in ID CS6 and CC
// (see animation)
const BEG = LocationOptions.AT_BEGINNING;
var TFS = app.activeDocument.textFrames;

source = TFS.itemByName('source').texts[0]; // Text: contains the anchor

host = TFS.itemByName('host'); // TextFrame: 'host' frame
dest = host.textFrames.itemByName('dest'); // TextFrame: 'dest' frame

source.move(BEG,dest); // --> ID crash
//source.move(BEG,host); // WOULD BE OK
//source.duplicate(BEG,dest); // WOULD BE OK

 

 

Thanks Marc for reporting the bug.

 

PS: Attached the InDesign test document with the named text frames.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Robert at ID-Tasker
Legend
April 20, 2023

What exactly do you mean by "inline"?

 

Community Expert
April 20, 2023

Hi @Phil 815 ,

also look into the TableCellBox.jsx script by Marc Autret:

https://github.com/indiscripts/IdGoodies/blob/master/snip/TableCellBox.jsx

 

The Magic Parent Bounding Box
Marc Autret, August 04, 2022

https://www.indiscripts.com/post/2022/08/magic-parent-bounding-box

 

And a discussion in German that inspired Marc Autret at hilfdirselbst.ch:

https://www.hilfdirselbst.ch/foren/Koordinaten_einer_Tabellenzelle_P583998.html

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Inspiring
June 6, 2023

The script is really amazing, but I managed to crash InDesign multiple times using it.

Im pretty sure the crash is caused by a table, that is inside an anchored text frame:

TextFrame → anchored TextFrame → Table     crashes every time
TextFrame → Table                          works reliably

 

Marc Autret
Legend
June 8, 2023

@m1b and @Marc Autret thanks a lot for your answers. 
I might not be able to look into it before next week, but I will definitely give you feedback. I will also check, if I can give you an IDML (it’s work for a customer).

Mark, your observation absolutely makes sense, as I have an anchor mark in each of these tables (actually finding these anchored objects is the starting point of my script). 


Hi all,

 

I didn't find any error in TableCellBox.jsx, matrices and transformations are properly calculated even in the Anchored-To-Anchored case reported by @C330 S. However, the line that makes ID crash is this one:

 

   sto.move(MX.loBEG,cell.texts[0].insertionPoints[0]);

 

which helps us identify the InDesign bug tucked behind the issue: given a Text objet source that contains an anchored object (AO), any attempt to move it into another AO will crash ID. The bug is not even related to Table or Cell objects.

 

 

// Tested in InDesign CS6/CC, Win10
// (see animation below)
// ---

TFS = app.activeDocument.textFrames;

source = TFS.itemByName('source').texts[0]; // Text: contains the anchor

host = TFS.itemByName('host');              // TextFrame: 'host' frame
dest = host.textFrames.itemByName('dest');  // TextFrame: 'dest' frame

//source.move(LocationOptions.AT_BEGINNING,host); // WOULD BE OK
source.move(LocationOptions.AT_BEGINNING,dest);   // --> ID crash

 

 

The bug seems specific to the move() method, regardless of whether it is invoked from a Text or a parent Story. Using duplicate() instead appears to work, so we could use that as a workaround (before removing the temporary frame). But duplicate() has a serious cost: it creates separate objects (new ids, etc.), which breaks the cellBox routine's commitment to remain transparent 😕😕

 

Maybe our friend @Laubender will find a way around this bad compromise. [Of course there is no hope that Adobe cares about this bug and tries to fix it. They focus on serious things: renaming masterpage to parentpage, etc]

 

Best,

Marc

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
April 20, 2023

Hi @Phil 815, I've written a script that includes a function getCellBounds. See this thread for the script. To get the bounds of a column (assuming that bounds of a cell wouldn't be adequate), you could calculate it similarly to the way getTableBounds function works. Let me know how you go.

- Mark

Phil 815
Phil 815Author
Inspiring
April 25, 2023

These answers were extremely helpful and got me to a solution. Thank you!