Copy link to clipboard
Copied
Hello - I am looking for help creating Javascript to remove Groups within Layers by Name. I began with an SVG file with different layers which I have subsequently saved as an AI file (Windows 7 Professional, Adobe Illustrator CS6). I now have many clipping mask bounding rectangles that cannot be removed, they are contained within groups named "SVGID." I previously ran a script to remove all clipping masks that deleted the unnecessary clipping paths, but I am still left with these SVIG groups that somehow contain the bounding rectangles. So I think the easiest way would be to run a script to remove all <Group> with name/label SVGID, but I am open to other suggestions. Thanks!!
Try to run it after changing "groupItems" to "pageItems". I hope that could help.
Copy link to clipboard
Copied
Moving to Illustrator Scripting​
Copy link to clipboard
Copied
Try the following snippet:
#target illustrator
function test(){
var doc = app.activeDocument;
var flag = true;
while(flag){
try {
doc.groupItems.getByName("SVGID").remove();
} catch(e) {
flag = false;
}
}
};
test();
Copy link to clipboard
Copied
Hi Silly-V - Thanks for the snippet. It does not seem to do anything on my end. After selecting all artwork in AI, I have saved the snippet as a jsx file (from Notepad) and executed it in AI by using File > Scripts > OtherScripts. All the SVGID groups are still there after these steps. Am I running the code incorrectly?
Copy link to clipboard
Copied
Try to run it after changing "groupItems" to "pageItems". I hope that could help.
Copy link to clipboard
Copied
Awesome, that worked, THANK YOU!