femkeblanco
Guide
femkeblanco
Guide
Activity
‎Aug 24, 2020
11:48 AM
1 Upvote
There is no function to "get" selected brushes, but you can still choose which brushes to randomly apply. In the snippet below, you choose a list of brushes based on a first and last. (Brushes are numbered starting with 1 from the panel's upper left .) firstBrushNo = 2; // <- enter number
lastBrushNo = 4; // <- enter number
theBrushes = app.activeDocument.brushes;
for (i = 0; i < app.selection.length; i++){
brushIndex = Math.floor(Math.random()*((lastBrushNo - 1) - (firstBrushNo - 1) + 1)) + (firstBrushNo - 1);
theBrushes[brushIndex].applyTo(app.selection[i]);
} For example, you can choose to randomly apply the brushes between the second and fourth (inclusive).
... View more
‎Aug 20, 2020
10:57 AM
app.selection[0].selectedPathPoints is a collection of selected points in a selected path. This is probably the closest thing to the Direct Selection Tool.
... View more
‎Aug 19, 2020
07:50 AM
You can do that with Astute Graphics' Stipplism plug-in. It's a paid for plug-in, but I seem to remember that they used to have a trial version. https://astutegraphics.com/plugins/stipplism
... View more
‎Aug 18, 2020
12:08 PM
1 Upvote
I've not tried it myself, but you could try Hiroyuki Sato's script "Join Reasonably". It has variables you could set: http://shspage.com/aijs/en/#join_reasonably
... View more
‎Aug 18, 2020
06:09 AM
1 Upvote
I thought app.executeMenuCommand("Live Pathfinder Add"); did that. Sorry, I'm not at my PC to check.
... View more
‎Aug 16, 2020
11:36 AM
Gotya. Still, redraw() counts as your last act, so one undo() will undo that but no further.
... View more
‎Aug 16, 2020
10:02 AM
undo() will undo the last act. If the last act was redraw(), I don't see how it can take you before that.
... View more
‎Aug 16, 2020
09:49 AM
You can easily toggle visibility of specific layers by scripting, if you can specifically target those layers. Presuming they are named, the easiest way would be to target their name or part of their name. For example, the snippet below will make all layers starting with the (capital) letter X invisible. for (var i = 0; i < app.activeDocument.layers.length; i++) {
var prefix = app.activeDocument.layers[i].name.substr(0, 1);
if (prefix == "X") {
app.activeDocument.layers[i].visible = false;
}
}
... View more
‎Aug 13, 2020
11:23 PM
I am wondering how you are moving pageItems from one layer to another, but regardless you should be able to delete empty layers at the end. Like m1b said, deleting items from a collection with forward iteration is problematic because of rearrangement, so you could try backward iteration. for (var i = app.activeDocument.layers.length - 1; i >= 0; i--) {
if (app.activeDocument.layers[i].pageItems.length == 0) {
app.activeDocument.layers[i].remove();
}
}
... View more
‎Aug 10, 2020
06:17 PM
It appears that there has since been a "clean out" and all the old stuff is gone. I found the particular thread you ask about through Wayback Machine. https://web.archive.org/web/20141202180523/https://forums.adobe.com/thread/1640679
... View more
‎Aug 08, 2020
12:53 PM
2 Upvotes
This will produce a list of the names of your fonts (saved in a text file to your desktop). (Change "Username" in the path in line 5 to your username.) var list1 = "";
for (var i = 0; i < textFonts.length; i++){
list1 = list1 + "\r" + i + " - " + textFonts[i].name;
}
var file1 = new File("/C/Users/Username/Desktop/fonts.txt");
file1.open("e");
file1.write(list1);
file1.close();
... View more
‎Aug 07, 2020
06:37 AM
What type of item is your non-native artwork? Both placedItems and rasterItems have "selected" properites, which when assigned "true", select the item.
... View more
‎Aug 01, 2020
03:38 AM
Try this: (It appears the word "path" is reserved or something like that.) var path1 = app.activeDocument.path;
var exportFolder = Folder(path1 + "/yourFolderName");
if (!exportFolder.exists){
exportFolder.create();
}
var file = new File(path1 + "/yourFolderName/yourFileName");
var PDF = new PDFSaveOptions;
app.activeDocument.saveAs(file, PDF);
... View more
‎Aug 01, 2020
03:09 AM
1 Upvote
To unlock all layers: var layers = app.activeDocument.layers;
for (var i = 0; i < layers.length; i++) {
layers[i].locked = false;
} To create folder and file, respectively (note the absolute path as I am unfamiliar with relative paths): var path1 = "/C/Users/Username/Desktop/yourFolderName/";
var folder1 = new Folder(path1);
folder1.create();
var file1 = new File(path1 + "yourFileName");
var PDF = new PDFSaveOptions;
app.activeDocument.saveAs(file1, PDF); So presumably your script would look something like this: var layers = app.activeDocument.layers;
for (var i = 0; i < layers.length; i++) {
layers[i].locked = false;
}
app.executeMenuCommand("unlockAll");
app.executeMenuCommand("selectall");
app.executeMenuCommand("OffsetPath v22");
app.executeMenuCommand("outline");
var path1 = "/C/Users/Username/Desktop/yourFolderName/";
var folder1 = new Folder(path1);
folder1.create();
var file1 = new File(path1 + "yourFileName");
var PDF = new PDFSaveOptions;
app.activeDocument.saveAs(file1, PDF);
... View more
‎Jul 31, 2020
10:29 AM
1 Upvote
I haven't used either myself, but to expand a path (brings up dialog box): executeMenuCommand("Expand3") or to outline a stroke: executeMenuCommand("OffsetPath v22")
... View more
‎Jul 31, 2020
02:07 AM
Please excuse the obvious question, but isn't a root directory required in the path in Windows? So var destFile = "/C/Users/andrey/Desktop";
... View more
‎Jul 28, 2020
06:05 AM
1 Upvote
Fred Brooks, in The Mythical Man-Month (The Bible of Software Engineering), states: "I will contend that Conceptual Integrity is the most important consideration in system design. It is better to have a system omit certain anomalous features and improvements, but to reflect one set of design ideas, than to have one that contains many good but independent and uncoordinated ideas." This is (not wholly) because if a system is too complicated to use, many features will go unused because no one has time to learn them.
... View more
‎Jul 26, 2020
11:27 PM
1 Upvote
Yes, math it is, but it shouldn't be that hard. All you need is to calculate the distances between the circle and the finalGroup and subtract these distances from the final position you want. var myDoc = app.activeDocument;
var square = myDoc.pathItems.rectangle(-100,100,100,100);
var circlemask = myDoc.pathItems.ellipse(-120,120,60,60);
var finalGroup = myDoc.groupItems.add();
square.moveToBeginning(finalGroup);
circlemask.moveToBeginning(finalGroup);
finalGroup.clipped = true;
var xInterval = circlemask.position[0] - finalGroup.position[0];
var yInterval = circlemask.position[1] - finalGroup.position[1];
finalGroup.position = [0 - xInterval, 0 - yInterval]; Caveats: (1) "position" does not include stroke weight, so you will have to calculate for that, and (2) the x and y elements cannot be assigned individually, i.e. "position" must be assigned an array [x, y].
... View more
‎Jul 26, 2020
03:47 PM
Yes, because the position of the finalGroup is the same as the position of the square (this is the case before and after you move it). The outer part of the square still exists, it's just hidden and not directly selectable from the artboard, but if you switch to Outline mode (Ctrl+Y) or select it from the layers panel, you'll see it still exists.
... View more
‎Jul 26, 2020
02:17 PM
Most items have a position property. So in the clipping mask from the preceding thread (Trying to assign a variable name to a masked object using a menu command in jsx), you can reassign the position of the whole "clipping set" group, clippingSet.position = [x, y]; just the "clipping path" clippingSet.pathItems["clippingPath"].position = [x, y]; or just the "masked artwork". clippingSet.pathItems["maskedArtwork"].position = [x, y]; The key is getting the hang of Illustrator's object model to be able to reference the items you want.
... View more
‎Jul 26, 2020
12:56 PM
3 Upvotes
move(), as I understand it, corresponds to the "Arrange" command in the Object menu. So, it "moves" a path above or below another path (in the example below, named path1 and path2). var paths = app.activeDocument.pathItems;
paths["path1"].move(paths["path2"], ElementPlacement.PLACEAFTER); It sounds like what you want is translate(dx, dy), which moves the path by dx and dy distances from the present position. So paths["path1"].translate(100, 100); moves the path 100 points in the positive x direction and 100 points in the positive y direction. Alternatively, you can assign new values for the position property: paths["path1"].position = [x, y]; I've not figured out how transform and transformation matrices work.
... View more
‎Jul 25, 2020
12:54 AM
1 Upvote
For non-grouped items vs groups: var groupNo = 0;
for (var i = 0; i < selection.length; i++) {
if (selection[i].typename == "GroupItem") {
groupNo = groupNo + 1;
}
}
var nonGroupNo = selection.length - groupNo;
alert("Non-grouped items: " + nonGroupNo + "\
Groups: " + groupNo + "\
Non-grouped items + groups: " + selection.length);
... View more
‎Jul 25, 2020
12:06 AM
In CS6, if a named element is not found, I get "Error 1302 : No such element." pointing to the line. Thanks for the script.
... View more
‎Jul 23, 2020
12:42 PM
1 Upvote
It's shorter and more intuitive (at least for me) to reference names using bracket notation. var layer2 = app.activeDocument.layers["firstLayer"].layers["secondLayer"];
... View more
‎Jul 22, 2020
03:51 AM
1 Upvote
Add this to the above to give your rectangle a black stroke: colour1 = new CMYKColor ();
colour1.cyan = 0;
colour1.magenta = 0;
colour1.yellow = 0;
colour1.black = 100;
rect.strokeColor = colour1;
... View more
‎Jul 22, 2020
03:25 AM
1 Upvote
Is your layer locked?
... View more
‎Jul 21, 2020
12:16 PM
3 Upvotes
Beginning with definitions (to void miscommunication): The path doing the masking is called a "clipping path". The path(s) being masked I will call "masked artwork". When you create a clipping mask, the "clipping path" and the "masked artwork" become a group, called a "clipping set". Correct me if I'm wrong, but you want to assign the "clipping set" to a variable, to be able to reference it. Since a "clipping set" is a group, you can create a group and assign it to a variable before you create a clipping mask and reference the (same) group afterwards. So (1) You have "masked artwork" in the background and you create a "clipping path". var paths = app.activeDocument.pathItems;
var maskedArtwork = paths["maskedArtwork"];
var clippingPath = paths.rectangle(-37.5*2.853, 37.5*2.853, 25*2.853, 25*2.853);
clippingPath.name = "clippingPath";
clippingPath.fillColor = app.activeDocument.swatches["CMYK Magenta"].color; (2) You create a group, assign it to a variable and move "masked artwork" and the "clipping path" into it. This will become the "clipping set" when you create a clipping mask. var clippingSet = app.activeDocument.groupItems.add();
clippingSet.name = "clippingSet";
maskedArtwork.moveToBeginning(clippingSet);
clippingPath.moveToBeginning(clippingSet); (3) You create a clipping mask, either by selecting the group and using executeMenuCommand or by setting clipped to true. clippingSet.selected = true;
app.executeMenuCommand("makeMask");
// clippingSet.clipped = true; (4) You can then reference the "clipping set" group by referencing the variable from step 2. For example, you can rotate the whole group. clippingSet.rotate(45); (5) Or you can individually reference the "clipping path" or "masked artwork" inside the "clipping set" group. For example, you can rotate just the "clipping path" or just the "masked artwork". // clippingSet.pathItems["clippingPath"].rotate(45);
// clippingSet.pathItems["maskedArtwork"].rotate(45); Easy peasy. (By the way, I am a beginner too, but it's a steep learning curve.) Reprise: var paths = app.activeDocument.pathItems;
var maskedArtwork = paths["maskedArtwork"];
var clippingPath = paths.rectangle(-37.5*2.853, 37.5*2.853, 25*2.853, 25*2.853);
clippingPath.name = "clippingPath";
clippingPath.fillColor = app.activeDocument.swatches["CMYK Magenta"].color;
var clippingSet = app.activeDocument.groupItems.add();
clippingSet.name = "clippingSet";
maskedArtwork.moveToBeginning(clippingSet);
clippingPath.moveToBeginning(clippingSet);
clippingSet.selected = true;
app.executeMenuCommand("makeMask");
// clippingSet.clipped = true;
clippingSet.rotate(45);
// clippingSet.pathItems["clippingPath"].rotate(45);
// clippingSet.pathItems["maskedArtwork"].rotate(45);
... View more
‎Jul 20, 2020
06:54 PM
1 Upvote
Try this: var coordinates = app.activeDocument.selection[0].visibleBounds;
var x1 = coordinates[0];
var y1 = coordinates[1];
var x2 = coordinates[2];
var y2 = coordinates[3];
var w = x2 - x1;
var h = y1 - y2;
var rect = app.activeDocument.pathItems.rectangle(y1, x1, w, h);
rect.strokeWidth = 1;
rect.filled = false;
... View more
‎Jul 19, 2020
12:35 PM
Using what CarlosCanto suggested does make it neater. (Enter your colour group name in the first line below.) var colorGroupName = "enter your color group name here";
var colorGroup = app.activeDocument.swatchGroups[colorGroupName].getAllSwatches();
var noOfColors = colorGroup.length;
var letters = app.activeDocument.textFrames[0].textRange.characters;
for (var i = 0; i < letters.length; i++) {
var x = Math.floor(Math.random() * noOfColors);
letters[i].fillColor = colorGroup[x].color;
}
... View more
‎Jul 19, 2020
02:15 AM
1 Upvote
Glad I could help.
... View more