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

Table's cells + GREP/Regex + diagonal lines

Explorer ,
Nov 15, 2022 Nov 15, 2022

Copy link to clipboard

Copied

Hello everyone.
I have that recuring problem of having huge tables, sometimes with 100+ cols and rows (litterally thousands of cells) and I need to "strike" the empty ones... Doing this by hand is tedious and as empty cells can be anywhere in table, alone or in a group, we are taking about some hours lost in Indesign void for nothing.

  • I know that you can easily add a diagonal line to a cell (or many at once if you have many selected) by using the "Table > Cell Options > Diagonal Lines" option upon a selection.
  • I know to REGEX my way of selection to only select the empty cells (with ^\Z), but the GREP search window does not seems to offer any cell options (like "diagonal lines") nor any cell style for that matter (which  forbid any kind of workaround using that way).

 

Does any one ever had this need and know a realistic way of processing this? I've tried with GREP/Regex, but I am stuck at the manipulation needed, and I've tried through the scripting way, be here to, I find very hard to get any type of clear documentation of cells caracteristic and "righ direction" hint. And I am not that good with scripting (btw if you have a really deep and good documentation, like a serious one, feel free to share. I found several but nothing like a full documentation, and far to be consistent or official...)

 

Thank you !

TOPICS
Feature request , Scripting

Views

1.2K

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 ,
Nov 15, 2022 Nov 15, 2022

Copy link to clipboard

Copied

Hi @jeromevadon ,

don't know how exactly you'll define an empty cell, but if you only aim at empty text cells, you could ask for its contents value. If that is an empty string, you could use all the properties for diagonalLine to draw one. Or apply a cell style that has the diagonal line defined in the manner you need it.

 

Basically it's this when a cell is selected and a cell style with name "diagonalLine" is defined:

var myCell = app.selection[0];
var digonalLineCellStyle = app.documents[0].cellStyles.itemByName("digonalLine");

if ( myCell.contents == "" )
{ myCell.appliedCellStyle = digonalLineCellStyle };

 

Regards,
Uwe Laubender
( Adobe Community Expert )

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 ,
Nov 15, 2022 Nov 15, 2022

Copy link to clipboard

Copied

Hi @Laubender,

Thank you very much for your message.
This sounds to be a very valuable way to solve my problem. I will try and test it!

Regards,

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 ,
Nov 15, 2022 Nov 15, 2022

Copy link to clipboard

Copied

@jeromevadon 

 

You'll need a script for this, you won't be able to do it in the interface (not reasonably, anyway). The script gets all the empty texts/stories using the GREP expression that you already use, then it cycles through them and applies a cell style to the cells that contain those empty strings. The cell style, which sets the diagonal line, as Uwe mentions, should be present. Here goes:

app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = '^\\Z';
cellStyle = app.documents[0].cellStyles.item ('diagonalLine');
empties = app.documents[0].findGrep();
for (i = 0; i < empties.length; i++) {
  if (empties[i].parent instanceof Cell) {
    empties[i].parent.appliedCellStyle = cellStyle;
  }
}

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
Community Expert ,
Nov 15, 2022 Nov 15, 2022

Copy link to clipboard

Copied

quote

… The cell style, which sets the diagonal line, … should be present …

 

By @Peter Kahrel

 

… and either named with the name "diagonalLine" (used in the script) or the name in Peter's script is changed to match the name of your cell style.

 




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 ,
Nov 15, 2022 Nov 15, 2022

Copy link to clipboard

Copied

Quite!

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 ,
Nov 15, 2022 Nov 15, 2022

Copy link to clipboard

Copied

Hi @Peter Kahrel 
During all my attempt to script something, the far I went, which was "somehow sometime" working (half working) was the following code

var allCells = app.selection[0].cells.everyItem().getElements();  
for ( var i = 0; i < allCells.length; i++)  
	{  
		if ( allCells[i].contents === '')  
		{  
			allCells[i].properties  = {
				topRightDiagonalLine : true
			};
		 }  
	 }   


I will try your code which looks much better than mine. I will let you know. Thanks so much for your time!

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 ,
Nov 15, 2022 Nov 15, 2022

Copy link to clipboard

Copied

Your code looks excellent! It's an entirely different approach.

You say that it wasn't always working. Do you know when and why?

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 ,
Nov 15, 2022 Nov 15, 2022

Copy link to clipboard

Copied

Is there a problem with .everyItem() function in JS ? On another thread someone have problem with links not updating properly?

 

â–’â–º ID-Tasker / ID-Tasker Server - work smart not hard â—„â–’

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 ,
Nov 16, 2022 Nov 16, 2022

Copy link to clipboard

Copied

Is there a problem with .everyItem() function in JS?

Never had a problem with it.

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 ,
Nov 16, 2022 Nov 16, 2022

Copy link to clipboard

Copied

Could you define "somehow sometime" working? Does the script miss some cells and work for some? Or is it that the script doesn't work at all sometimes and does work sometimes? If it is the later option, then probably you have different kind of selections when it works and when it does not. Adding a log for allCells.length might help to debug

-Manan

 

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 ,
Nov 17, 2022 Nov 17, 2022

Copy link to clipboard

Copied

Thank you for your message.


I was not able to find any pattern nor detect any related behavior leading to "not working". Running this script on the same selection will work most of time (maybe 90%) but, sometimes will not work or partially work. Run it again, and then it work. Maybe. Or not.

 

And that makes it not reliable, therefore I needed to think of a different approach.

 

That said, despiste have "more than good enought" computer (with a lot of RAM), I came to the idea that, maybe, in some extrem scenario, the buffer needed to execute the script was just not enough to complete or to render. As this would be related to the memory allocated to the process at a give time, it also depends of whatever the host is also doing on the background... I have no idea of what I am talking here, just an idea.

 

I like the log idea... except I don't know how to this (just add a log line ?). I will Google it later. To be honnest I've already given up on this code, which I was just bringing up as example of my faillure... But as all of you, whom are much more expert than me, seems to consider it ok; I will give it another chance..

 

Is there an official and updated documentation for script within Idesign ? I found a lot of non official litterature, websites and posts, but nothing Adobe official (and updated! I found few years old ones). 

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 ,
Nov 17, 2022 Nov 17, 2022

Copy link to clipboard

Copied

Hi @jeromevadon ,

the one thing I can offer is the link to the DOM (Document Object Model) description of InDesign 2023 compiled by Gregor Fellenz:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#about.html

( But you may have already found that… )

 

Regards,
Uwe Laubender
( Adobe Community Expert )

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 ,
Nov 17, 2022 Nov 17, 2022

Copy link to clipboard

Copied

Nop, this one is much more recent than the one i had. Thank you so much !

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 ,
Nov 17, 2022 Nov 17, 2022

Copy link to clipboard

Copied

LATEST

I want here ot thanks all of you for the quality of your answers and feeback! This is great to see this!

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