I'm trying to select every object with the color "CutContour"
So far I've been trying:
myDoc.selection = myDoc.spots.getByName("CutContour");
I guess this obviouslly wouldn't work though because myDoc.selection is looking for an array of objects.
However, I can't figure out how to loop through all the objects in the document and check to see if they contain the SpotColor.
Any help would be incredibly appreciated!
EDIT:
I want to use the Select > Same > Stroke Color , but I heard that using that in Javascript isn't available unless you have CS6 (which I currently don't). Is it true that accessing menu items through scripting is a feature in CS6?
Yes you can't do this as straight forward as you hoped… In script probably the same as is done in those app/plug-in's you will need to loop through all the art items and test each in turn… Depending upon your art in question this can become a very complex routine… Why are you trying to select this stuff?
doc.selection = [ wants an array of objects ]
myDoc.spots.getByName("CutContour") is only going to find an object reference to a spot swatch in the document swatches panel if it exists…
You can't put these together like you have done…
To your edit Yes its a new thing with CS6… I don't have this either… boo
Thanks for clearing some of that up for me!
I only need to select path items, and I see that if I do something along the lines of:
var objects = myDoc.pageItems;
I can get an array of all the items in my document. However, I'm trying to figure out where to go from here, but the process seems overly complex. I want to loop through objects and see if they are pathitems, and then check to see if they have the color I'm looking for, but I can't find the strokeColor property in the Javascript reference. Also, what about compoundPathItems (closed paths)? If I check for PathItems, will I also get CompoundPathItems?
EDIT:
This is what I have so far, however, it is not working correctly /:
var myColor = myDoc.spots.getByName("CutContour");
var arrObj = [];
for (var i = 0; i <objects.length; i++) {
if (objects[i].typename == "PathItem" && objects[i].fillColor == myColor) {
arrObj.push(objects[i]);
objects[i].move(layer_Cut, ElementPlacement.PLACEATBEGINNING);
}
}
See, the whole goal is to move all objects with the color "CutContour" to
pageItems is a super class like swatches It covers a few common/shared properties but under each are sub-classes that contain more specific properties…
getting pageItems will return an array but it could be mix of [ pathItem, textItem, groupItem etc. ]
getting swatches could return [ spot, rgb, cmyk, gradient etc. ]
If you are wanting to access only pathItems then access that collection at what ever object level you want to deal with… e.g.
var a = doc.pathItems;
You can check the collections length property and create a loop…
For each item you can test the pathItem for it's .fillcolor & .strokecolor properties
North America
Europe, Middle East and Africa
Asia Pacific