Copy link to clipboard
Copied
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.clipp
...
Copy link to clipboard
Copied
With two objects selected this script will resize the width of top object to match the width of bottom object:
function resizeZero() {
var aDoc = app.activeDocument;
var Zero = selection[0];
var One = selection[1];
Zero.width = One.width;
redraw();
}
resizeZero();
Copy link to clipboard
Copied
What is required is that the height of 1 becomes the height of 2, the width is increased in the same proportion, and the clipping mask is supported.
Copy link to clipboard
Copied
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();
Copy link to clipboard
Copied
Thanks Sergey Osokin the script works perfectly