Copy link to clipboard
Copied
Is there a way to raster selection, or do I have to create layers/groups and move them group by group? Just thought I would ask if it's possible before diving in. Thought something like this may work but I get an illegal argument when running.
idoc.rasterize( selection, rasteroptions);
Copy link to clipboard
Copied
jeremy0013 hello!
You are trying to pass a special object selection, but the method 'Document.rasterize()' expects source art(s):
activeDocument.rasterize(selection[0]);
Copy link to clipboard
Copied
I think you have to move them into a group, or use an action to rasterize without having to move into a group.
On an added note:
app.executeMenuCommand("raster"); <-- this actually puts the preview to Pixel preview!
and:
app.executeMenuCommand("Rasterize 8 menu item"); <-- this activates the Rasterize dialog, but cannot be done without the dialog, hence why you have to do the action.
Copy link to clipboard
Copied
Thanks O and V for your reply. I have been messing around with O's solution due to having a non user interface. I think the objects will have to be grouped before rasterization as when rasterizing it only does one object and not all. And here comes the next question, how to move the selected objects to a layer after grouping them so that the groups can be rasterized one at a time. Any help would be appreciated.
var newoptions = new RasterizeOptions;
newoptions.resolution = 150;
newoptions.transparency = true;
function SelectRaster() {
var idoc = activeDocument;
var artbs = idoc.artboards;
for (var i = artbs.length-1 ; i >= 0; i--) {
if (artbs.name != "Void") {
artbs.setActiveArtboardIndex(i);
idoc.selectObjectsOnActiveArtboard();
//Layer and sort groups.
}}
};
SelectRaster();
Rasterize layer groups. Already have this part figured out.
Copy link to clipboard
Copied
What is the purpose of all these manipulations? Describe your problem completely, please.
Copy link to clipboard
Copied
I have multiple artboards with layered graphics I need to flatten and rasterize per artboard. Make sense. The rasterization I already have figured out but need to group the selection of each artboard and get it to a layer for rasterization. I guess this could all be done with one function but my javascript skills are not that far along yet.
update: Almost have it. Moving artboard objects to layer, rasterizing on to the next artboard. V was right, have to group objects before rasterizing.
Copy link to clipboard
Copied
/**
* group all anlock and visible items on each top-layers
* compatible CS6+
*
* @param {Document} d - object of Illustrator DOM Document class
* */
function groupOnLays(d) {
executeMenuCommand('deselectall');
var lays = d.layers;
for (var i = 0; i < lays.length; i++) {
var lay = lays;
lay.hasSelectedArtwork = true;
executeMenuCommand('group');
lay.hasSelectedArtwork = false;
}
}
groupOnLays(activeDocument);
Find more inspiration, events, and resources on the new Adobe Community
Explore Now