• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

Script to Pathinder > 'Crop' clip groups

New Here ,
Mar 10, 2022 Mar 10, 2022

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:

example.jpg

 

 

 

 

 

 

 

 


.
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:

Steve23534591lq4l_0-1646955090168.png

 

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

 

 

 

TOPICS
Scripting

Views

251

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 10, 2022 Mar 10, 2022

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
...

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 10, 2022 Mar 10, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 10, 2022 Mar 10, 2022

Copy link to clipboard

Copied

Ah thanks Mark, that's perfect šŸ™‚ Appreciate the help mate!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 11, 2022 Jun 11, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2022 Jun 11, 2022

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines