femkeblanco
Guide
femkeblanco
Guide
Activity
‎Jul 19, 2020
02:02 AM
1 Upvote
OK. I don't know that much about swatches, so someone might know an easier way. But since you're adding swatches to the end of the panel, I've targeted the collection backwards. So try this: (This will target the last six swatches.) var min = app.activeDocument.swatches.length - 6;
var max = app.activeDocument.swatches.length - 1;
var letters = app.activeDocument.textFrames[0].textRange.characters;
for (var i = 0; i < letters.length; i++) {
var x = Math.floor(Math.random() * (max - min + 1)) + min;
letters[i].fillColor = app.activeDocument.swatches[x].color;
}
... View more
‎Jul 19, 2020
01:21 AM
Can you take a screen shot of your swatches panels?
... View more
‎Jul 19, 2020
01:05 AM
Copy and paste it in a jsx file. (You can create a txt file and change the extension to jsx.) Then, while your document is open in Illustrator, go to File > Scripts > Other Script (Ctrl+F12). Find your script and open it.
... View more
‎Jul 19, 2020
12:34 AM
Assuming one textFrame and six swatches, try this: var letters = app.activeDocument.textFrames[0].textRange.characters;
for (var i = 0; i < letters.length; i++) {
var x = Math.floor(Math.random() * (7 - 1)) + 1;
letters[i].fillColor = app.activeDocument.swatches[x].color;
}
... View more
‎Jul 17, 2020
01:57 PM
1 Upvote
This should (1) delete layer 2, save the doc with layer 1 as AI, undo delete, (2) delete layer 1, save the doc with layer 2 as PDF and undo delete again. If you want it the other way around, swap the layers' names. (Replace "..." in the path in line 3 below with your destination.) var layer1 = app.activeDocument.layers["Layer 1"];
var layer2 = app.activeDocument.layers["Layer 2"];
var file1 = new File("/C/Users/.../Desktop/yourFileName");
var PDF = new PDFSaveOptions;
layer2.remove();
app.activeDocument.saveAs(file1);
app.undo();
layer1.remove();
app.activeDocument.saveAs(file1, PDF);
app.undo();
... View more
‎Jul 16, 2020
07:18 AM
1 Upvote
No, that's just me not knowing how to use constants as arguments. Thanks.
... View more
‎Jul 15, 2020
10:42 AM
This should vertically scale down selected objects 9 mm from top and 9 mm from bottom. for (var i = 0; i < selection.length; i++) {
var percentage = ((selection[i].height - (9*2*2.835)) / selection[i].height) * 100;
selection[i].resize(100, percentage, true, false, false, false, 0, selection[i].scaleAbout = Transformation.CENTER);
}
... View more
‎Jul 14, 2020
02:00 PM
app.activeDocument.graphicStyles["[Default]"].applyTo(app.activeDocument.pathItems["yourPathItemName"]); removes all appearance attributes, including brush.
... View more
‎Jul 14, 2020
12:57 PM
Your question is very nonspecific, but here are the basic steps: (1) read a file and (2) add the text to a layer (in this case, as area type). (Replace "..." with the address to your file name.) var address1 = "/C/Users/.../yourFileName.txt";
var file1 = new File(address1);
file1.open("e");
var contents1 = file1.read();
file1.close(); var doc1 = app.activeDocument;
var layer1 = doc1.layers.add();
var path1 = layer1.pathItems.rectangle(0, 0, doc1.width, doc1.height);
var text1 = activeDocument.textFrames.areaText(path1);
text1.contents = contents1;
... View more
‎Jul 14, 2020
10:00 AM
No, to my knowledge that is not possible (I am happy to be corrected).
... View more
‎Jul 14, 2020
09:58 AM
It works fine for me in CS6. Please excuse the obvious question: There is no function call in the above snippet; you are calling the function exportToPNGFile("your path..."), aren't you?
... View more
‎Jul 13, 2020
10:57 PM
1 Upvote
A clipping mask is just a group with the "clipped" perperty set to true. So you can create a group (either manually or through a script) and assign it to a variable and then create a clipping mask from that group. var mask = app.activeDocument.groupItems["your_group_name"];
mask.selected = true;
app.executeMenuCommand('makeMask');
... View more
‎Jul 13, 2020
10:15 PM
1 Upvote
You can set the units when you create a new document: var preset1 = new DocumentPreset;
preset1.units = RulerUnits.Inches;
var doc1 = app.documents.addDocument("Basic CMYK", preset1); but I don't think you can change them after that. app.executeMenuCommand("unitundoPref") brings up the units dialog box, but you will have to select your units manually.
... View more
‎Jul 13, 2020
12:26 PM
1 Upvote
executeMenuCommand(), as the name implies, executes a command from a menu (File, Edit, Object, et cetera). Most of these commands have shortcuts, but to execute a command through a script, you need to specify the command to be executed. For example app.executeMenuCommand("zoomin"); zooms in (Ctrl+plus) and app.executeMenuCommand("group"); groups selected items (Ctrl+G). So what you need is the parameter representing the command, not the command's shortcut. What commands are you looking to execute?
... View more
‎Jul 12, 2020
12:54 AM
I think the key to predicting the appearance of a compound path is that it's all about the first item moved into it. So, first, the colour will be that of the first item moved into it, regardless of whether it's moved to the end or beginning. (This is contrary to creating a compound path through the menu, in which the colour will be the that of the bottom-most item.) And, second, the "evenodd" property (which when true creates a hole out of every other region, but which by default is set to false, producing an unpredictable non-zero winding compound path) has to be set for the first item moved into it. I think that all holed paths (at least in CS6) are compound paths. Original evenodd set for path1 & path1 moved first var path1 = selection[0]; // yellow
var path2 = selection[1]; // magenta
var path3 = selection[2]; // cyan
path1.evenodd = true;
var compound1 = app.activeDocument.compoundPathItems.add();
path1.moveToEnd(compound1);
path2.moveToEnd(compound1);
path3.moveToEnd(compound1); evenodd set for path3 & path3 moved first var path1 = selection[0]; // yellow
var path2 = selection[1]; // magenta
var path3 = selection[2]; // cyan
path3.evenodd = true;
var compound1 = app.activeDocument.compoundPathItems.add();
path3.moveToEnd(compound1);
path1.moveToEnd(compound1);
path2.moveToEnd(compound1);
... View more
‎Jul 06, 2020
02:04 PM
Try this: var part1 = app.activeDocument.layers["Invoice_#"].textFrames[0].contents;
var part2 = app.activeDocument.layers["Customer"].textFrames[0].contents;
var address = "‪/C/Users/asparaccio/Desktop/" + part1 + "_" + part2;
var file1 = new File(address);
var PDF = new PDFSaveOptions;
app.activeDocument.saveAs(file1, PDF); The last one only saved as "_.pdf" because the textFrames are not named (but showing their contents).
... View more
‎Jul 06, 2020
12:19 PM
So "1600" and "Peter" are not sublayers then, but items (of some type). So try this: var item1 = app.activeDocument.layers[1].pageItems[0];
var item2 = app.activeDocument.layers[2].pageItems[0];
var address = "‪/C/Users/.../Desktop/" + item1.name + "_" + item2.name;
var file1 = new File(address);
var PDF = new PDFSaveOptions;
app.activeDocument.saveAs(file1, PDF); Edit: Following what pixxxel_schubser said below, presuming these are textFrames, try this instead: (this won't work if contents is >1 line) var part1 = app.activeDocument.layers["Invoice_#"].textFrames[0].contents;
var part2 = app.activeDocument.layers["Customer"].textFrames[0].contents;
var address = "‪/C/Users/.../Desktop/" + part1 + "_" + part2;
var file1 = new File(address);
var PDF = new PDFSaveOptions;
app.activeDocument.saveAs(file1, PDF);
... View more
‎Jul 06, 2020
11:38 AM
Going by your photo, you want to target the first sublayer in the second and third layers. So try this: (again fill in "..." in your path) var sublayer1 = app.activeDocument.layers[1].layers[0];
var sublayer2 = app.activeDocument.layers[2].layers[0];
var address = "‪/C/Users/.../Desktop/" + sublayer1.name + "_" + sublayer2.name;
var file1 = new File(address);
var PDF = new PDFSaveOptions;
app.activeDocument.saveAs(file1, PDF);
... View more
‎Jul 06, 2020
11:07 AM
The file name is the last part of the path. So you can use a layer's name as the last part of the path. For example, you can use the name of the layer which is active: (you will need to fill in "..." in your path) var layer1 = app.activeDocument.activeLayer;
var address = "‪/C/Users/.../Desktop/" + layer1.name;
var file1 = new File(address);
var PDF = new PDFSaveOptions;
app.activeDocument.saveAs(file1, PDF); Or you can use a joining of the names of the first and second layers: var layer1 = app.activeDocument.layers[0];
var layer2 = app.activeDocument.layers[1];
var address = "‪/C/Users/.../Desktop/" + layer1.name + layer2.name;
var file1 = new File(address);
var PDF = new PDFSaveOptions;
app.activeDocument.saveAs(file1, PDF); Et cetera. (Of course, you can also enter the layers' names directly into the path if you want.)
... View more
‎Jun 27, 2020
09:24 AM
Please excuse the obvious question, but why not export as TIF? ExportOptionsTIFF has a "resolution" property.
... View more
‎Jun 22, 2020
10:18 AM
1 Upvote
The "typename" of text is "TextFrame". So try this: var group = app.activeDocument.layers["Icon"].groupItems[0];
for (var i = (group.pageItems.length) - 1; i >= 0; i--) {
if (group.pageItems[i].typename == "TextFrame") {
group.pageItems[i].remove();
}
}
... View more
‎Jun 14, 2020
06:27 PM
1 Upvote
Sorry. There was an "app." missing. I don't need to make app explicit in CS6. var items = app.activeDocument.pathItems;
var groups = app.activeDocument.groupItems;
for (var i = 0; i < items.length; i++){
for (var j = items.length - 1; j > i; j--){
if (items[i].left == items[j].left){
var group = groups.add();
group.name = "group" + i;
items[i].moveToEnd(groups[group.name]);
items[j].moveToEnd(groups[group.name]);
}
}
}
... View more
‎Jun 14, 2020
05:42 PM
Try this for grouping 2 paths with same X var items = app.activeDocument.pathItems;
var groups = app.activeDocument.groupItems;
for (var i = 0; i < items.length; i++){
for (var j = items.length - 1; j > i; j--){
if (items[i].left == items[j].left){
var group = groups.add();
group.name = "group" + i;
items[i].moveToEnd(groups[group.name]);
items[j].moveToEnd(groups[group.name]);
}
}
}
... View more
‎Jun 13, 2020
05:09 PM
Sorry. I didn't test it for selected items. You are right, it doesn't work for selected items (I'm not sure why off the top of my head). However, it should work for all paths in the document: function sortLtoR(items){
for (var i = (items.length - 1); i >= 0; i--){
for (var j = 1; j <= i; j++){
if (items[j-1].left < items[j].left){
items[j].moveBefore(items[j-1]);
}
}
}
}
sortLtoR(app.activeDocument.pathItems);
... View more
‎Jun 13, 2020
04:24 PM
1 Upvote
You could try a compound path. // select 2 paths
var path1 = selection[0];
var path2 = selection[1];
path2.evenodd = true;
var compound1 = app.activeDocument.compoundPathItems.add();
path2.moveToEnd(compound1);
path1.moveToEnd(compound1);
... View more
‎Jun 13, 2020
07:22 AM
Try this // select items to sort
function sortLtoR(items){
for (var i = (items.length - 1); i >= 0; i--){
for (var j = 1; j <= i; j++){
if (items[j-1].left < items[j].left){
items[j].moveBefore(items[j-1]);
}
}
}
}
sortLtoR(selection);
... View more
‎Jun 13, 2020
02:04 AM
The guide states that "the layer and group item classes can contain nested objects of the same class which can, in turn, contain additional nested objects". So I understand why I use recursion to iterate over nested layers. But I can iterate over all groupItems, including nested groupItems, directly without recursion. (I presume that "child" groupItems are added to the "parent" groupItems collection.) My question is: Why the difference? Thanks in advance. var theLayers = activeDocument.layers;
var theList = "";
for (var i = 0; i < theLayers.length; i++) {
theList = theList + theLayers[i].name + "\r";
}
alert(theList);//Layer 1 Layer 2 (i.e. parent layers only) var theItems = activeDocument.groupItems;
var theList = "";
for (var i = 0; i < theItems.length; i++) {
theList = theList + theItems[i].name + "\r";
}
alert(theList);//A1 A2 A2a A2a1 (i.e. parent and child groupItems)
... View more
‎Jun 08, 2020
08:15 AM
If you are the author, if you have permission from the author or if the author has made a script free to use and distribute, then you are free to share. Adobe has no say in the matter.
... View more
‎Jun 08, 2020
04:21 AM
2 Upvotes
Yes, you are absolutely right. It should be var group = app.activeDocument.layers["Icon"].groupItems[0];
for (var i = (group.pageItems.length) - 1; i >= 0; i--) {
if (group.pageItems[i].typename == "CompoundPathItem") {
group.pageItems[i].remove();
}
} Thank you.
... View more
‎Jun 07, 2020
01:24 PM
1 Upvote
This will delete the last item in the first group in the "Icon" layer. var group = app.activeDocument.layers["Icon"].groupItems[0];
var lastIndex = (group.pageItems.length) - 1;
group.pageItems[lastIndex].remove(); Alternatively, this will loop through the items in the first group in the "Icon" layer and delete compound paths. var group = app.activeDocument.layers["Icon"].groupItems[0];
for (var i = 0; i < group.pageItems.length; i++) {
if (group.pageItems[i].typename == "CompoundPathItem") {
group.pageItems[i].remove();
}
} Neither the group nor the items in the group are named, so they cannot be deleted by name.
... View more
- « Previous
- Next »