Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

Select All and Scale

$
0
0

AI CS5 Win 7 Javascript (Novice)

 

I am working on a script to scale all objects in a document to a percentage, based on a selection...

 

Basically, I am scaling 2D barcodes.  Each "Module" (individual square) in the code needs to be 2pts (Or close).  So, my idea was for the user to select one module and run the script. The script will get the size of the module, and figure the percentage needed to make it 2 pts.  Then select everything and apply the scaling.

 

I have figured out how to find the scale based on an object selected.  I could use a little help on the next steps (As I see it):

 

Select all

Group selected

Scale

 

This is what I have now:

 

// Active Doc

var docRef = app.activeDocument

 

 

// Get selection size

var Selected=docRef.selection[0]

var objectBounds = Selected.visibleBounds;

var W = objectBounds[2] - objectBounds[0];    // the width

 

 

// Find the percentage for scaling

var scaleX = Math.round((2/W) * 100);

var scaleY = scaleX;

$.write (scaleX) // for testing

//Select all

 

 

// Scale Selected Items

// .resize(scaleX, scaleY);

 

Thank you for any assistance...

kaz


Viewing all articles
Browse latest Browse all 12845

Trending Articles



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