Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for professional graphic designers and non-designers trying to do their own graphic design. It's 100% free, no registration required.

I'm writing a script for Illustrator CS5 to resize my artwork (and artboards and a whole lot of other stuff in a batch).

I'm having severe issues with the javascript functions resize() and transform(). When I scale my object manually inside Illustrator (double clicking on the scale tool or using the transform dialog), I can select "Scale Stroke and Effects" and scaling looks fine.

I scale this down to 20%:

Original:

And I get this (which is fine):

Scaled with scale dialog

Now, when I use the resize() or transform() functions in Illustrator's scripting I get this:

Scaled with script

The simple script to reproduce:

var doc = app.activeDocument;
var item = doc.pageItems[0];
item.resize(
    20.0, // x
    20.0, // y
    true, // changePositions
    true, // changeFillPatterns
    true, // changeFillGradients
    true, // changeStrokePattern
    true , // changeLineWidths
    undefined); // scaleAbout

I have tried playing around with the parameters to resize() but nothing comes close to the transform dialog in Illustrator.

The original .ai file can be downloaded from here.

So my question is: How can I get the same effect from javascript as I can from using the built in transform dialog ?

share|improve this question
add comment

1 Answer

Turns out that the (badly named IMHO) "changeLineWidths" parameter is not a boolean but a scaling factor just like the x and y parameters.

So this is solved like this:

var scale = 20; // scale down to 20%
item.resize(
    scale , // x
    scale , // y
    true, // changePositions
    true, // changeFillPatterns
    true, // changeFillGradients
    true, // changeStrokePattern
    scale , // changeLineWidths    <----  NOTE THIS
    undefined); // scaleAbout

(IMHO "changeLineWidths" should be named "scaleLineWidths" just like the first two are named "scaleX" and "scaleY" in the documentation.)

Hope this helps someone else!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.