Quantcast
Channel: Adobe Community : Discussion List - Illustrator Scripting
Viewing all articles
Browse latest Browse all 3671

resizing width of a selected object.

$
0
0

Trying to get a very simple script to adjust for the slight distortion that happens when a printing plate is wrapped around the print cylinder. Basically I need to condense the image width wise only (not the height) so it will compress something like 95-98% of it's original width but the height will be the same.

 

I tried to make a fairly basic script to do this, but it keeps telling me "selectedObject.resize is not a function". Ultimately my idea was to create a variable called condenseRatio that would be the percentage I would reduce the width by, because not every plate would reduce by the same percentage. The distortion changes based on which print cylinder is chosen, so wherever the left x value of the repeating image is determines what percentage the image will need to be condensed. Currently I've just got the resize set to 90% of width just to see if I can get it going, and worry about using a variable number there later. So far, no go.

 

Here's what I've cobbled together:

 

// required: an open document and a selected path item 

 

var myDocument = app.activeDocument; 

var selectedObject = myDocument.selection; 

 

//Identify left edge of repeat 

var repeatBounds = app.activeDocument.groupItems['repeat'].geometricBounds; 

var r1 = repeatBounds[0]; 

 

// Get position of selection bounds and create condense ratio 

var myBounds = selectedObject[0].geometricBounds; 

var x1 = myBounds[0]; 

var x2 = myBounds[2];

var rawRepeat = (r1 - x1);

var rawGap = (r1 - x2);

var rawPrintWidth = myBounds[2] - myBounds[0];

var condenseRatio = (rawPrintWidth / rawRepeat) * 100;

 

selectedObject.resize(

    90.0, // x

    100.0, // y

    true, // changePositions

    true, // changeFillPatterns

    true, // changeFillGradients

    true, // changeStrokePattern

    true , // changeLineWidths

    undefined); // scaleAbout

 

Any help on what I'm doing wrong would be greatly appreciated.

 

Thanks in advance.


Viewing all articles
Browse latest Browse all 3671

Trending Articles



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