[Help] Illustrator Scale script by user defined percentage
Hello,
This is my first post here,
I am trying to create my first script to scale objects from each object's origin(center), not the overall origin.
The script goes like this:
1. You select the objects you want to scale
2. Run the script
3. Enter the scale value (just like the Scale tool in illustrator) (e.g. 50%)
4. The selected objects will be scaled by the value you entered. (e.g. 50%)
I can't figure out how to connect the value you enter to the scale function part. (textNewScale)
var totalMatrix = concatenateScaleMatrix( scaleMatrix, textNewScale, textNewScale);- line 60 in the below script
Here is the full script
(function () {
// The script code goes inside this anonymous function.
// Reusable UI variables
var g; // group
var p; // panel
var w; // window
// Permanent UI variables
var btnCancel;
var txtScaleSizeInput;
var btnOk;
var txtFolderInput;
var textNewScale
textNewScale =
// CREATE USER INTERFACE
w = new Window("dialog", "Adobe Script Tutorial 1");
p = w.add("panel");
g = p.add("group");
txtScaleSizeInput = g.add("edittext", undefined, textNewScale, {
borderless: "true",
name: textNewScale,
});
txtScaleSizeInput.preferredSize = [100, -1];
g.alignChildren = "center";
g = w.add("group");
g.alignChildren = "center";
btnOk = g.add("button", undefined, "OK");
btnCancel = g.add("button", undefined, "Cancel");
// UI EVENT HANDLERS
btnOk.onClick = function () {
w.close(1);
};
btnCancel.onClick = function () {
w.close(0);
};
// SHOW THE WINDOW
// w.show();
if (w.show() == 1) {
// alert("OK was clicked");
process();
}
function process() {
if ( app.documents.length > 0 ) {
var moveMatrix = app.getTranslationMatrix ( 0.5, 1.5 );
var scaleMatrix = app.getScaleMatrix (100, 100);
var totalMatrix = concatenateScaleMatrix( scaleMatrix, textNewScale, textNewScale);
var doc = app.activeDocument;
for ( i = 0; i < activeDocument.selection.length; i++ ) {
activeDocument.selection[i].transform( totalMatrix );
}
}
}
})();
Thank you
