Answered
How to copy height to another object in illustrator script? thanks
How does the script change the height of object 1 to the height of object 2? thanks
How does the script change the height of object 1 to the height of object 2? thanks
Quick modification. The clipping mask can be a group of paths or text in Adobe Illustrator. Then the code won't work. I didn't make it complicated. But in your example you have a mask from a simple path.
function resizeZero() {
var aDoc = app.activeDocument;
var zero = selection[0];
var one = selection[1];
var coeff = Math.abs(getHeight(one) / getHeight(zero) * 100);
zero.resize(coeff, coeff);
redraw();
}
function getHeight(item) {
return (item.typename == 'GroupItem' && item.clipped) ? getMaskPath(item).height : item.height;
}
function getMaskPath(group) {
for (var i = 0; i < group.pageItems.length; i++) {
var item = group.pageItems[i];
if ((item.typename === 'CompoundPathItem' && item.pathItems[0].clipping) || item.clipping) {
return item;
}
}
}
resizeZero();
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.