Hi everyone,
I am a newbie of script things,
Can you help me to define the "FillTint" and "StrokeWeight"
and when I press cancel, It always give an error.
//---------------------------------------------------------------------------------------- --------------------------------------------------------------------------------
if ( app.selection.length > 0 && ( app.selection[0].constructor.name == "Cell" || app.selection[0].constructor.name == "Table" ) ) {
if ( app.scriptPreferences.version >= 6 ) {
app.doScript( main, ScriptLanguage.JAVASCRIPT , [], UndoModes.ENTIRE_SCRIPT, "style every second column in selection" );
}
else {
main();
}
} else {
alert ( "Nothing or wrong selection!" );
}
function main() {
var
w = new Window("dialog","What is your choice", undefined, {closeButton: false}),
mPanel1 = w.add ("panel",undefined, "Fill Color"),
mPanel2 = w.add ("panel",undefined, "Fill Tint"),
mPanel3 = w.add ("panel",undefined, "Stroke Color"),
mPanel4 = w.add ("panel",undefined, "Stroke Weight"),
mPanel5 = w.add ("panel",undefined, "Character Style"),
//---------------------------------------------------------------------------------------- ----------------------------------------------
mCoList = mPanel1.add("dropdownlist",undefined,app.activeDocument.swatches.everyItem().name),
mFillTint = mPanel2.add("dropdownlist", undefined, ["15%","20%","25%","30%"]),
mStCoList = mPanel3.add("dropdownlist",undefined,app.activeDocument.swatches.everyItem().name),
mStWeightList = mPanel4.add("dropdownlist", undefined, ["0.5pt","1pt","1.5pt","2pt"]),
mStyList = mPanel5.add("dropdownlist",undefined,app.activeDocument.characterStyles.everyItem().name) ,
//---------------------------------------------------------------------------------------- --------------------------------------------------------
b = w.add("group");
mCoList.items[0].selected = mStyList.items[0].selected = true;
w.alignChildren= "left";
b.add ('button', undefined, "OK", {name: "ok"});
b.add ('button', undefined, "取り消す", {name: "cancel"});
if (w.show()) {
//---------------------------------------------------------------------------------------- --------------------------------------------------------------------
var myColor = mCoList.selection.text;
var mFillTint = // I don't know how to define fill tint
var myStrokeColor = mStCoList.selection.text;
var StrokeWeight = // I don't know how to define stroke weight
var myCharStyleName = mStyList.selection.text;
//---------------------------------------------------------------------------------------- --------------------------------------------------------------------
}
else exit();
var curSel = app.selection[0];
var allCells = curSel.cells;
var startCol = curSel.cells[0].name.split(":")[0]*1;
var endCol = curSel.cells[-1].name.split(":")[0]*1;
var startRow = curSel.cells[0].name.split(":")[1]*1;
var endRow = curSel.cells[-1].name.split(":")[1]*1;
var counter = startCol + 1;
for ( var i = 0 ; i < allCells.length; i++ ) {
var curCell = allCells[i];
var curCol = curCell.name.split(":")[0]*1;
var curRow = curCell.name.split(":")[1]*1;
if ( curCol == counter ) {
with ( curCell ) {
fillColor = myColor;
fillTint = myFillTint;
texts[0].appliedCharacterStyle = myCharStyleName;
rightEdgeStrokeWeight = myStrokeWeight;
rightEdgeStrokeColor= myStrokeColor;
leftEdgeStrokeWeight = myStrokeWeight;
leftEdgeStrokeColor= myStrokeColor;
}
if ( curRow == startRow ) {
curCell.topEdgeStrokeWeight = myStrokeWeight;
curCell.topEdgeStrokeColor= myStrokeColor;
}
else if (curRow == endRow ) {
curCell.bottomEdgeStrokeWeight = myStrokeWeight;
curCell.bottomEdgeStrokeColor= myStrokeColor;
}
counter = counter + 2;
}
if ( counter > endCol ) {
counter = startCol + 1;
} // end if
} // end for
} // end main
//---------------------------------------------------------------------------------------- --------------------------------------------------------------------------------
thanks
Jone