• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Illustrator Script - release clipping mask

Explorer ,
May 25, 2023 May 25, 2023

Copy link to clipboard

Copied

Is there a way to script the selection of a a clipping mask named "UNC" and have it release the clipping mask "<clip group>" its a part of, leaving all other clipping masks in other clip groups alone? I've tried several ways, but can't get the script to work. Here's what i have so far: 

 

var clippingMaskName = "UNC";

function findAndReleaseClippingMask(currentGroup) {
  for (var i = 0; i < currentGroup.pageItems.length; i++) {
    var currentItem = currentGroup.pageItems[i];
    if (currentItem.name === clippingMaskName && currentItem.typename === "PathItem" && currentItem.clipping) {
      app.activeDocument.selection = null;
      currentGroup.selected = true;
      app.executeMenuCommand("unlockMask");
      app.executeMenuCommand("releaseMask");
      return;
    }

    if (currentItem.typename === "Group") {
      findAndReleaseClippingMask(currentItem);
    }
  }
}
findAndReleaseClippingMask(app.activeDocument.groupItems[0]);

 

TOPICS
Scripting

Views

445

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

Guide , May 25, 2023 May 25, 2023
var _name = "UNC";
var groups = app.activeDocument.groupItems;
for (var i = 0; i < groups.length; i++) {
    if (groups[i].name == _name && groups[i].clipped == true) {
        // 1 unclip
        groups[i].clipped = false;
        // 2 ungroup
        for (var j = groups[i].pageItems.length - 1; j > -1 ; j--) {
            groups[i].pageItems[j].moveAfter(groups[i]);
        }
    }
}

Votes

Translate

Translate
Adobe
Guide ,
May 25, 2023 May 25, 2023

Copy link to clipboard

Copied

var _name = "UNC";
var groups = app.activeDocument.groupItems;
for (var i = 0; i < groups.length; i++) {
    if (groups[i].name == _name && groups[i].clipped == true) {
        // 1 unclip
        groups[i].clipped = false;
        // 2 ungroup
        for (var j = groups[i].pageItems.length - 1; j > -1 ; j--) {
            groups[i].pageItems[j].moveAfter(groups[i]);
        }
    }
}

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
Explorer ,
May 25, 2023 May 25, 2023

Copy link to clipboard

Copied

LATEST

thank you, that worked perfectly.

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