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

[SCRIPT] AlternatingFills

Enthusiast ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

Hello, there.

I'm trying to change the alternatingFills in an existing table.

I'm using variables to swatches and tints.

tab.alternatingFills = AlternatingFillsTypes.ALTERNATING_ROWS;
tab.startRowFillColor = s1;
tab.endRowFillColor = s2;
tab.startRowFillTint = t1;
tab.endRowFillTint = t2;

But nothing happens. Any help?

TOPICS
Scripting

Views

445

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

Community Expert , Apr 16, 2021 Apr 16, 2021

Hi lf.corullon,

without looking into your sample document:

Could be that the cell properties have style overrides.

Just try to change the table in the UI without a script.

Will the alternate rows be visible as expected?

No? Overrides are there.

 

You now could:

A. Tackle all the overrides by scripting or

B. You could simply write a script that is doing the fills directly on the cells for every other row.

 

B. is easier…

 

Regards,
Uwe Laubender

( ACP )

Votes

Translate

Translate
Community Expert ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

Works for me, what error did you get? I used the following code

var tab = app.selection[0]
var s1 = app.documents[0].swatches.itemByName("s1")
var s2 = app.documents[0].swatches.itemByName("s2")
var t1 = 10
var t2 = 20
tab.alternatingFills = AlternatingFillsTypes.ALTERNATING_ROWS;
tab.startRowFillColor = s1;
tab.endRowFillColor = s2;
tab.startRowFillTint = t1;
tab.endRowFillTint = t2;

-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
Enthusiast ,
Apr 16, 2021 Apr 16, 2021

Copy link to clipboard

Copied

Yes, that's almost the same I have here.

It works on "new" tables. Not on the ones the document came with.

I tried to attach an IDML document (but Adobe said the file extension does not correspond – HAHAHAHAHA). So, here is a link to the IDML sample document: https://corullon.com.br/lf/aarquivoslfc/test_filling.idml.

The top table doesn't look affected by the script. The bottom one, has the expected result.

 

For me, when I select the first table and run the script, and then right click to see Table Options and Alternating Fills, the color and tint fields are empty, but when I click on color dropdown arrow, the color set in the script looks pre-selected.

 

Thanks for your help, 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
Community Expert ,
Apr 16, 2021 Apr 16, 2021

Copy link to clipboard

Copied

Hi lf.corullon,

without looking into your sample document:

Could be that the cell properties have style overrides.

Just try to change the table in the UI without a script.

Will the alternate rows be visible as expected?

No? Overrides are there.

 

You now could:

A. Tackle all the overrides by scripting or

B. You could simply write a script that is doing the fills directly on the cells for every other row.

 

B. is easier…

 

Regards,
Uwe Laubender

( ACP )

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
Enthusiast ,
Apr 16, 2021 Apr 16, 2021

Copy link to clipboard

Copied

Thank you, Uwe.

Doing the alternating fills manually works.

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 ,
Apr 16, 2021 Apr 16, 2021

Copy link to clipboard

Copied

Yes, with your document and the first table in that text frame I see the issue.

For the second table all is working as expected with my code below.

Also if I draw out a new table.

var tab = app.selection[0].parentStory.tables[0];

tab.properties =
{
	alternatingFills : AlternatingFillsTypes.ALTERNATING_ROWS,
	
	columnFillsPriority : false ,
	
	startRowFillCount : 1 ,
	endRowFillCount : 1 ,
	
	startRowFillColor : "s1" ,
	startRowFillTint : 20 ,
	
	endRowFillColor : "s2" ,
	endRowFillTint : 20

};

Regards,
Uwe Laubender

( ACP )

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
Enthusiast ,
Apr 16, 2021 Apr 16, 2021

Copy link to clipboard

Copied

Yes, that's exactly the problem.

I need to work on that first table.

 

Better to force the fills row by row with script as you mentioned before?

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 ,
Apr 16, 2021 Apr 16, 2021

Copy link to clipboard

Copied

Hm. No. You could perhaps "restore" such a table. Removing overrides to a destinct level.

Marc Autret once did a script for this. After done apply your formatting with alternating rows.

 

Breaking Link to Cell/Table Style in the Selection

Marc Autret, June 19, 2014

https://www.indiscripts.com/post/2014/06/indesign-scripting-forum-roundup-6#hd2sb4

 

// LEVEL 0  => only clear overrides relative to *defined* style attrs
// LEVEL 1  => clear all overrides (through root style)  
// LEVEL 2  => clear all overrides and apply [None]  
// LEVEL 3  => apply [None] *in depth* (i.e. release all attributes)

 

Did not test Marc's code with the 4 different levels on your problem table; hope it will work as first step.

Just an idea…

 

Regards,
Uwe Laubender

( ACP )

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
Enthusiast ,
Apr 16, 2021 Apr 16, 2021

Copy link to clipboard

Copied

LATEST

It works. But all other properties are clear.

My client formatted the tables manually, no styles except paragraph styles.

With Marc's ultra deep (and scary) cleaner, strokes and text styles looks reseted...

 

Thanks for trying to help, Uwe. Much appreciated, as always.

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