Copy link to clipboard
Copied
This script question is basic. How would i go about making a script that makes the selection Solid Black? I think i could do this in Indesign but I'm finding that illustrator is not the same in scritping
It depends on what you have selected. For example you can have raster images, but they won't change color, or what if you had something with a fill and stroke , would you want both to be black?
Assuming you are just dealing with paths which have fills, you can apply the following snippet to give them the "Black" color of your document's swatches. The good thing is, your paths can be grouped or be compound paths, etc.
#target illustrator
function test(){
var doc = app.activeDocument;
doc.defaultFi
...Copy link to clipboard
Copied
Depends upon what kind of object the selection is. For a simple pathItem, you can do this:
var docRef = app.activeDocument;
var blackColor = new CMYKColor();
blackColor.black = 100;
var sel = docRef.selection;
//assuming there's only one item selected
//if multiple items are selected, you just do this part in a loop
sel[0].fillColor = blackColor;
if you have groupItems you'll likely need some recursive functionality (unless you can rely on a consistent structure of the group, in which case you could target the underlying pathItems specifically, but this isn't very scalable and thus, a bad idea).
If you give more information about the file you're working with and the exact structure of the objects and what not, i can give a more specific answer.
Copy link to clipboard
Copied
It depends on what you have selected. For example you can have raster images, but they won't change color, or what if you had something with a fill and stroke , would you want both to be black?
Assuming you are just dealing with paths which have fills, you can apply the following snippet to give them the "Black" color of your document's swatches. The good thing is, your paths can be grouped or be compound paths, etc.
#target illustrator
function test(){
var doc = app.activeDocument;
doc.defaultFillColor = doc.swatches.getByName("Black").color;
};
test();
Copy link to clipboard
Copied
Sorry i should have specified. This is only for certain Guide marks such as "eyemarks/CropMarks" etc.. i have selected. Both stroke and Fill. I really only need it for all the RICH BLACK marks i have on the documents.
Thanks to you both for replying.
Copy link to clipboard
Copied
Thanks both of you. I used Silly-V's script (Slightly Modified) just because it was simpler to add the stroke as well.
#target illustrator
function test(){
var doc = app.activeDocument;
doc.defaultFillColor = doc.swatches.getByName("Black").color;
doc.defaultStrokeColor = doc.swatches.getByName("Black").color;
};
test();