Copy link to clipboard
Copied
I want to select an object with a clipping mask with the selection tools (V). Then run the script that can select only the mask path, so that I can modify it. Then when I run the script again the selection is back to the previous state. How to write a script that does this. I would appreciate your help.
var target = app.selection[0];
if (target.typename == "PathItem" &&
target.clipping == true) {
exit(target)
function exit(target) {
if (target.parent.typename != "Layer") {
exit(target.parent)
} else {
target.selected = true;
}
}
} else {
var clippingPath;
var items = target.pageItems;
enter(items);
if (clippingPath) {
app.selection = null;
clippingPath.selected = true;
}
function enter(items...
In case there is an urgent reason to first select the clipping group with the Selection tool (V), you may also just select and then isolate and edit it (by clicking the Isolate Mask button in the Properties panel, by right clicking on the clipping group and choosing the Isolate Selected Mask command, or by assigning and using a keyboard shortcut to enter Isolation mode (see Edit menu > Keyboard Shortcuts > Menu Commands > Other Object > Isolate Selected Object)).
I don't see a reason why a scr
...Copy link to clipboard
Copied
Do you really need a script to do that?
Wouldn't it be easier to assign a keyboard shortcut to the Object menu > Clipping Mask > Edit Mask command and just use this route?
Or directly selecting the clipping path with the Direct Selection tool or the Group Selection tool?
Copy link to clipboard
Copied
Hey when using the Edit Mask command, the objects inside the mask are selected, not the mask path. I would like to select the mask path and edit it with one keyboard shortcut.
Copy link to clipboard
Copied
If you select the object with the clipping mask, you already select the mask.
All you need to do is switch to the Direct Selection tool (A) and click an anchor point to edit the mask.
Copy link to clipboard
Copied
var target = app.selection[0];
if (target.typename == "PathItem" &&
target.clipping == true) {
exit(target)
function exit(target) {
if (target.parent.typename != "Layer") {
exit(target.parent)
} else {
target.selected = true;
}
}
} else {
var clippingPath;
var items = target.pageItems;
enter(items);
if (clippingPath) {
app.selection = null;
clippingPath.selected = true;
}
function enter(items) {
for (var i = items.length - 1; i > -1; i--) {
if (items[i].typename == "GroupItem" ||
items[i].typename == "CompoundPathItem") {
enter(items[i].pageItems);
} else if (items[i].typename == "PathItem" &&
items[i].clipping == true) {
clippingPath = items[i];
}
}
}
}(If there are >1 clipping mask in the selected item, the topmost clipping path will be selected.)
Copy link to clipboard
Copied
In case there is an urgent reason to first select the clipping group with the Selection tool (V), you may also just select and then isolate and edit it (by clicking the Isolate Mask button in the Properties panel, by right clicking on the clipping group and choosing the Isolate Selected Mask command, or by assigning and using a keyboard shortcut to enter Isolation mode (see Edit menu > Keyboard Shortcuts > Menu Commands > Other Object > Isolate Selected Object)).
I don't see a reason why a script would be necessary or more beneficial in that case.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more