Releasing AI clipping masks with javascript
#1
Posted 14 May 2012 - 04:15 PM
I am exporting a large number of maps from AutoCAD to Illustrator and I need a way to release all the clipping masks that get exported. Is there a way to do this with javascript? I haven't been able to find any command for editing clipping masks in javascript.
Thank you!
#2
Posted 15 May 2012 - 03:49 AM
Look in the Illustrator Javascript reference, and there is a clipped attribute to e.g. groupItems. Or if the structure of the documents is predictable you can just remove the first item in a group.
#3
Posted 15 May 2012 - 03:50 AM
#4
Posted 22 May 2012 - 03:42 PM
/* remove clipping paths from main layers */
for (var ii = newLayerCount - 1; ii >= 0; ii--) {
var topLayer=myDoc.layers[ii];
for(p=topLayer.groupItems.length - 1;p>=0; p--){
if(topLayer.groupItems[p].pathItems.clipping = true){
topLayer.groupItems[p].pathItems[0].remove()}
}
}
/* remove clipping paths from sub layers */
for (var ii = newLayerCount - 1; ii >= 0; ii--) {
var topLayer=myDoc.layers[ii];
if(topLayer.layers.length>0){
for(var iii = topLayer.layers.length - 1; iii >= 0; iii--){
var subLayer = topLayer.layers[iii];
subLayer.visible = true
subLayer.locked = false
for(s=subLayer.groupItems.length - 1;s>=0;s--){
if(subLayer.groupItems[s].pathItems.clipping = true){
subLayer.groupItems[s].pathItems[0].remove()}
}
}
}
}
#5
Posted 07 January 2013 - 05:13 PM
Hey,
I ran across this thread awhile ago and was also having problems with clipping masks.
I got your script running Brian, but it wasn't quite what I needed.
Revisiting this problem after doing a lot of reading through the Adobe javascript manuals, I believe I've found a simpler solution.
The script still cycles through items looking for clipping masks to remove, but I realized I could loop through all the page items without having to "drill down" through layers, sublayers and groups looking for path item clipping masks.
Here is the script (it also includes a "clipping mask counter" that can be commented out... I just like to know how many items get deleted when I run something like this):
#target Illustratorvar docRef = app.activeDocument;var clippingCount = 0clipScan()//loops through all pageItems, removing those that are clipping masksfunction clipScan () {for (i=docRef.pageItems.length-1;i>=0;i--) {if (docRef.pageItems[i].type = [PathItem]){if (docRef.pageItems[i].clipping == true){docRef.pageItems[i].remove();clippingCount++;}}}};alert ("All "+clippingCount+" Clipping Masks Removed")
If you find an issue with this you're welcome to drop me a line over on the Adobe forums... I actually just joined this forum because I thought I'd save anyone else trying to figure this out a bit of work! I appreciated your code and figured I could do the same. :-D
Cheers!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users


Sign In
Create Account
United States
Back to top
Sweden
No Country Selected








