Copy link to clipboard
Copied
Hey Adobians 🙂
I was wondering if someone had a script, or could help me tweak a script that can target all layers named <clip group> and process them via the 'Crop' Pathfinder tool.
Attached is an ai file with an example floorplan, which is riddled with with these clip groups, as screenshotted:
.
If I process/remove these clip groups in any other way.. the result is not desired, e.g. this doorway clip group would collapse and appear as a solid wall basically:
I set these floorplans to be interactive on a website, and unfortunately if I don't process these clip groups before uploading it to the web, they all appear like this doorway>wall.
----- ----- ----- ----- -----
I did spot this script on the web, but unfortunately it processes the clip groups to the undesired result screenshotted above ^ I'm not sure how to tweak it so it processes clip groups via the Pathfinder crop tool.
var docRef = app.activeDocument;
var clippingCount = 0
clipScan()
//loops through all pageItems, removing those that are clipping masks
function clipScan () {
for (i=docRef.pageItems.length-1;i>=0;i--) {
if (docRef.pageItems[i].clipping == true){
docRef.pageItems[i].remove();
clippingCount++;
}
}
};
alert ("All "+clippingCount+" Clipping Masks Removed")
Any assistance would be much appreciated 🙂
Thanks,
Steve
Hi @Steve23534591lq4l, I made some adjustments to your script:
clipScan(app.activeDocument);
function clipScan(doc) {
// loops through all groupItems, removing those that are clipping masks
var clippingCount = 0;
for (i = doc.groupItems.length - 1; i >= 0; i--) {
if (doc.groupItems[i].clipped == true) {
doc.selection = [doc.groupItems[i]];
app.executeMenuCommand('Live Pathfinder Crop');
app.executeMenuCommand('expandStyle');
cl
...
Copy link to clipboard
Copied
Hi @Steve23534591lq4l, I made some adjustments to your script:
clipScan(app.activeDocument);
function clipScan(doc) {
// loops through all groupItems, removing those that are clipping masks
var clippingCount = 0;
for (i = doc.groupItems.length - 1; i >= 0; i--) {
if (doc.groupItems[i].clipped == true) {
doc.selection = [doc.groupItems[i]];
app.executeMenuCommand('Live Pathfinder Crop');
app.executeMenuCommand('expandStyle');
clippingCount++;
}
}
doc.selection = null;
alert("All " + clippingCount + " clipping masks expanded.")
};
You were targetting the wrong page items I think. I targetted groupItems that are "clipped" rather than pageItems that are "clipping".
- Mark
Copy link to clipboard
Copied
Ah thanks Mark, that's perfect 🙂 Appreciate the help mate!
Copy link to clipboard
Copied
If you want to change to process only the currently selected
How to modify this script, do not want to deal with all the objects within the document
Copy link to clipboard
Copied
Hi @X242795006zn0, then it would be something like this:
clipScan(app.activeDocument);
function clipScan(doc) {
// loops through all groupItems, removing those that are clipping masks
var clippedGroups = [];
// store the target groupItems
for (var i = 0; i < doc.groupItems.length; i++) {
if (
doc.groupItems[i].selected == true
&& doc.groupItems[i].clipped == true
) {
clippedGroups.push(doc.groupItems[i]);
}
}
var clippingCount = 0;
for (i = clippedGroups.length - 1; i >= 0; i--) {
doc.selection = [clippedGroups[i]];
app.executeMenuCommand('Live Pathfinder Crop');
app.executeMenuCommand('expandStyle');
clippingCount++;
}
doc.selection = null;
alert(clippingCount + " clipping masks expanded (out of " + clippedGroups.length + " selected).");
};
This time, it checks if group item is clipped and selected. We have to do 2 loops because the pathFinder commands mess up the current selection. The first loop collects all the groupItems we want and the second does the pathfinder.
- Mark