Copy link to clipboard
Copied
I would like to know how to check if the selected object has a clipping mask, and resize the clipping mask to the active artboard. Please let me know if you have any additional info about that.
Hi @StefanStehlik, I wrote a quick script that tries to do what you described. Please give it a try and let me know how it goes.
- Mark
/**
* Resize Clipping Mask To Active Artboard Rect.
*/
(function () {
var doc = app.activeDocument,
item = doc.selection[0];
resizeClippingMaskToActiveArtboard(item);
/**
* Resizes item's clipping mask
* to match artboard bounds.
* @author m1b
* @version 2022-10-20
* @param {GroupItem} item - an Illustrator Gr
...
Copy link to clipboard
Copied
Clipping masks appear on the opacity and appearance panel, but in order to resize them independently you will need to release them so they behave like regular objects. Probably something that would be a good candidate for creating a little script so it can be done with a button click...
Mylenium
Copy link to clipboard
Copied
Clipping masks appear on the opacity and appearance panel,
By @Mylenium
They appear in the Layers panel.
Copy link to clipboard
Copied
Yeah, sorry, my bad. Was probably thinking about some other stuff.
Mylenium
Copy link to clipboard
Copied
Hi,
I want to resize the visible artwork too, it is possible ?
Actually, I want to resize all the clip group to 50X70 cm
Copy link to clipboard
Copied
My request solved here !!
Copy link to clipboard
Copied
Double click on the object/shape to adjust the clipping mask. double click outside the object/shape to exit the clipping mask.
And i think it would be easier to resize the artboard to the clipping mask if that's also an option. -> Click on the clipping mask with the artboard tool.
Copy link to clipboard
Copied
Hi @StefanStehlik, I wrote a quick script that tries to do what you described. Please give it a try and let me know how it goes.
- Mark
/**
* Resize Clipping Mask To Active Artboard Rect.
*/
(function () {
var doc = app.activeDocument,
item = doc.selection[0];
resizeClippingMaskToActiveArtboard(item);
/**
* Resizes item's clipping mask
* to match artboard bounds.
* @author m1b
* @version 2022-10-20
* @param {GroupItem} item - an Illustrator GroupItem with clipping mask.
* @returns {Boolean} - success.
*/
function resizeClippingMaskToActiveArtboard(item) {
if (
item == undefined
|| !item.hasOwnProperty('clipped')
|| item.clipped !== true
)
// no clipping mask
return;
var mask;
for (var i = 0; i < item.pageItems.length; i++) {
if (item.pageItems[i].clipping == true) {
mask = item.pageItems[i];
break;
}
}
if (mask == undefined)
return false;
// get item's parent document
var doc = item;
while (
doc.hasOwnProperty('parent')
&& doc.constructor.name != 'Document'
)
doc = doc.parent;
var ab = doc.artboards[doc.artboards.getActiveArtboardIndex()],
bounds = ab.artboardRect;
// set mask size to match artboard rect
mask.position = [bounds[0], bounds[1]];
mask.width = bounds[2] - bounds[0];
mask.height = -(bounds[3] - bounds[1]);
};
})();
Copy link to clipboard
Copied
Thank you, this is what I'm looking for
Copy link to clipboard
Copied
I'm unsure if the OP wants to resize just the clipping path, a la @m1b 's script, or resize the visible artwork too.
Copy link to clipboard
Copied
Yep, I'm unsure too. @StefanStehlik, feel free to post more specific details if you need to.
- Mark