Quantcast
Channel: Adobe Community : All Content - All Communities
Viewing all articles
Browse latest Browse all 290743

Add rounding to this script

$
0
0

Hi everyone,

 

I need to add rounding to this script. I need two versions, one for 1 decimal place and one for 0 decimal places. Can anyone help out?

 

 

#target illustrator

 

addMeasurements();

 

function addMeasurements() {

   

    var i, doc, imp, met, txtItems, txt, nub;

 

    doc = app.activeDocument;

 

    imp = doc.layers.getByName( 'Text' );

 

    met = doc.layers.add();  met.name = 'New';

         

    txtItems = imp.textFrames;

 

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

 

        txtItems[i].duplicate( met, ElementPlacement.PLACEATEND )

 

    };

 

    txtItems = met.textFrames;

 

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

 

        var nub = parseInt( txt = txtItems[i].contents ); // For Numbers only!!!!

       

        txtItems[i].contents = String( txt * 1.1 )

 

    };

 

};

 

 

Thanks in advance.


Viewing all articles
Browse latest Browse all 290743

Trending Articles



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