Quantcast
Channel: Adobe Community : Popular Discussions - InDesign Scripting
Viewing all articles
Browse latest Browse all 15932

How can I show the swatches.everyItem in the dropdown list

$
0
0

Hi, everyone

 

Can you correct my script, aim to let it show the swatches.everyItem in the dropdown list

 

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!" ); 
}

 

//---------------------------------------------------------------------------------------- --------------has some prolems in this part


var sN = doc.swatches.everyItem ().name, 
    sID = doc.swatches.everyItem ().id,

 

function main() {

   var l, c = 0, o, p, pO = {}, pA = []; 
     if (s == null) {alert("No Swatch Selected") ; return;};               // I want to show swatches.everyItem.name as myColor
    s = doc.swatches.itemByID (sID[s.index]);

//---------------------------------------------------------------------------------------- --------------has some prolems in this part

 

 


    var myFillTint = 20; 
    var myCharStyleName = "Bold"; 
    var myStrokeWeight = 0.5; 
 
    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= myColor;  
                leftEdgeStrokeWeight = myStrokeWeight; 
                leftEdgeStrokeColor= myColor;                  
            } 
            if ( curRow == startRow ) { 
                curCell.topEdgeStrokeWeight = myStrokeWeight; 
                curCell.topEdgeStrokeColor= myColor; 
            } 
            else if (curRow == endRow ) { 
                curCell.bottomEdgeStrokeWeight = myStrokeWeight; 
                curCell.bottomEdgeStrokeColor= myColor; 
            } 
             
            counter = counter + 2; 
        } 
         
        if ( counter > endCol ) { 
            counter = startCol + 1; 
        } // end if 
    } // end for 
} // end main

 

 

John


Viewing all articles
Browse latest Browse all 15932

Trending Articles