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

A better way to write this.

$
0
0

My hope was to run through the list of inks and check each ink to see if it matched with a name in my array and then assign a value. I was attempts were unsuccessful. So I went with a bunch of if statements. I know I should be able to reduce this down and say if variable ink ==name in this array assign it this value from this array.

When I make a second loop to get to the array name the first loop does not work.

I just need a point in the right direction.

 

 

myDocument=app.activeDocument;

densityChange();

function densityChange(){

 

/*for (i=0; i<myDocument.swatches.length; i++){

                name = myDocument.swatches[i].name;

              //neutralDensity

    

     alert(name);

     }

}

*/

var ssDensityChng=(["203 Mandarin","201 Orange","601 Purple","202 Met Orange","302 Yellow","401 Bright Grn","301 Golden Yel","106 Bright Red","104 Cadmium Red","102 Maroon","103 Dark Red","101 Burgundy","501 Met Blue","602 Met Purple","404 Met Sage","712 Bronze","704 Silver","702Met Pewter"]);

var myDensity=([0.0341,0.0699,0.1076,0.1473,0.1892,0.2337,0.281,0.3315,0.3858,0.4444,0.508,0. 5776,0.6545,0.7403,0.8375,0.9493,1.0813,1.242]);

for (i=0; i<myDocument.inks.length; i++){

                var name = myDocument.inks[i].name;

                var density = myDocument.inks[i].neutralDensity;

                if(name== "203 Mandarin"){

                density=myDocument.inks[i].neutralDensity=0.0341;

                }

                if(name=="201 Orange"){

                density=myDocument.inks[i].neutralDensity=0.0699;

                }

                if(name=="601 Purple"){

                density=myDocument.inks[i].neutralDensity=0.1076;

                }

                if(name=="202 Met Orange"){

                density=myDocument.inks[i].neutralDensity=0.1473;

                }

                if(name=="302 Yellow"){

                density=myDocument.inks[i].neutralDensity=0.1892;

                }

                if(name=="401 Bright Grn"){

                density=myDocument.inks[i].neutralDensity=0.2337;

                }

                if(name=="301 Golden Yel"){

                density=myDocument.inks[i].neutralDensity=0.281;

                }

                if(name=="106 Bright Red"){

                density=myDocument.inks[i].neutralDensity=0.3315;

                }

                if(name=="104 Cadmium Red"){

                density=myDocument.inks[i].neutralDensity=0.3858;

                }

                if(name=="102 Maroon"){

                density=myDocument.inks[i].neutralDensity=0.4444;

                }

                if(name=="103 Dark Red"){

                density=myDocument.inks[i].neutralDensity=0.508;

                }

                if(name=="101 Burgundy"){

                density=myDocument.inks[i].neutralDensity=0.5776;

                }

                if(name=="501 Met Blue"){

                density=myDocument.inks[i].neutralDensity=0.6545;

                }

                if(name=="602 Met Purple"){

                density=myDocument.inks[i].neutralDensity=0.7403;

                }

                if(name=="404 Met Sage"){

                density=myDocument.inks[i].neutralDensity=0.8375;

                }

                if(name=="712 Bronze"){

                density=myDocument.inks[i].neutralDensity=0.9493;

                }

                if(name=="704 Silver"){

                density=myDocument.inks[i].neutralDensity=1.0813

                }

                if(name=="702Met Pewter"){

                density=myDocument.inks[i].neutralDensity=1.242;

                }

           

           }

    }


Viewing all articles
Browse latest Browse all 15932

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>