Hi all,
I think I had to split this topic part!
[ see: How to quickly change cell stroke weight ]
Here's 2 variants of a tool thought by Uwe Laubender, Skemicle and your servant!
This 1rst script allows the op to change to 0.5 pt the cell stroke weights in all the tables in a document if they are not equal to zero.
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
app.doScript ( main, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Change Tables Stroke Weights!" );
function main()
{ var newWeight = 0.5; if(app.documents.length == 0){return}; if(app.documents[0].stories.length == 0){return}; if(app.documents[0].stories.everyItem().tables.length == 0){return}; var doc = app.documents[0]; var allStories = doc.stories.everyItem(); var allCells = allStories.tables.everyItem().cells.everyItem().getElements(); for(var n=0;n<allCells.length;n++) { if(allCells[n].topEdgeStrokeWeight != 0){ if(allCells[n].topEdgeStrokeWeight != newWeight){ allCells[n].topEdgeStrokeWeight = newWeight } } }; for(var n=0;n<allCells.length;n++) { if(allCells[n].bottomEdgeStrokeWeight != 0){ if(allCells[n].bottomEdgeStrokeWeight != newWeight){ allCells[n].bottomEdgeStrokeWeight = newWeight } } }; for(var n=0;n<allCells.length;n++) { if(allCells[n].leftEdgeStrokeWeight != 0){ if(allCells[n].leftEdgeStrokeWeight != newWeight){ allCells[n].leftEdgeStrokeWeight = newWeight } } }; for(var n=0;n<allCells.length;n++) { if(allCells[n].rightEdgeStrokeWeight != 0){ if(allCells[n].rightEdgeStrokeWeight != newWeight){ allCells[n].rightEdgeStrokeWeight = newWeight } } };
};
This second script allows the op to choose what cell stroke weights in all the tables in a document he wants to change (to 0.5 pt):
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
app.doScript ( main, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Change Stroke Weight" );
function main()
{
var weight = Number(prompt("What is your starting weight?", 1,"Current Stroke Weight"));
var newWeight = 0.5;
if(app.documents.length == 0){return};
if(app.documents[0].stories.length == 0){return};
if(app.documents[0].stories.everyItem().tables.length == 0){return};
var doc = app.documents[0];
var allStories = doc.stories.everyItem();
var allCells = allStories.tables.everyItem().cells.everyItem().getElements();
for(var n=0;n<allCells.length;n++)
{ if(allCells[n].bottomEdgeStrokeWeight != weight){continue}; allCells[n].bottomEdgeStrokeWeight = newWeight;
};
for(var n=0;n<allCells.length;n++)
{ if(allCells[n].leftEdgeStrokeWeight != weight){continue}; allCells[n].leftEdgeStrokeWeight = newWeight;
};
for(var n=0;n<allCells.length;n++)
{ if(allCells[n].rightEdgeStrokeWeight != weight){continue}; allCells[n].rightEdgeStrokeWeight = newWeight;
};
for(var n=0;n<allCells.length;n++)
{ if(allCells[n].topEdgeStrokeWeight != weight){continue}; allCells[n].topEdgeStrokeWeight = newWeight;
};
};
I think it would be cooler to have this UI and this game:
• type * if the op wants to treat all the strokes (except 0);
• type a number if he wants to treat a specific stroke weight.
![Capture d’écran 2016-08-17 à 16.49.54.png]()
I get this UI like this:
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
app.doScript ( main, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Change Tables Stroke Weights!" );
// Here's the UI
var w = new Window ('dialog {alignChildren: "right"}', 'Change Tables Stroke Weights!');
var group1 = w.add ('group'); group1.add ('statictext {text: "Cells stroke to be replaced:"}'); var UIWeight = group1.add ("edittext", undefined, 1); UIWeight.minimumSize.width = 50; UIWeight.maximumSize.width = 50; UIWeight.active = true; var group2 = w.add ('group'); group2.add ('statictext {text: "… by:"}'); var UINewWeight = group2.add ("edittext", undefined, 0.5); UINewWeight.minimumSize.width = 50; UINewWeight.maximumSize.width = 50; var buttons = w.add ('group {alignment: "center"}'); buttons.add ('button {text: "OK"}'); buttons.add ('button {text: "Cancel"}');
if (w.show() == 2) { // Cancel pressed exit();
}
// Now the script:
function main()
{
… But, at this step, I'm totally unable to continue! …
Thanks for all your help and your nice advices to not to sink in the dark side of The Force!
MTFBWY!