femkeblanco
Guide
femkeblanco
Guide
Activity
‎Jul 27, 2023
12:50 AM
1 Upvote
When you distort an item with an envelope, you create an unnamed pluginItem. So, unless you name it, you cannot target it by name. If it's always the topmost item in the "base" layer or the one pluginItem in the "base" layer, you could target it that way.
... View more
‎Jul 20, 2023
03:00 AM
Je ne pense pas que ce soit possible. https://illustrator.uservoice.com/forums/931888-illustrator-ipad-feature-requests/suggestions/41707726-add-right-to-left-rtl-language-support
... View more
‎Jul 10, 2023
01:11 PM
The second script works fine for me. If it is not working, there might be an error in myPhotoshopScript.jsx itself.
... View more
‎Jun 29, 2023
12:44 PM
3 Upvotes
// select item
var item = app.selection[0];
var origin = item.fillColor.origin[0];
var length = item.fillColor.length;
var bounds = item.geometricBounds;
var bound1 = bounds[0];
var bound2 = bounds[0] + (bounds[2] - bounds[0]);
var gradient1 = item.fillColor.gradient;
stop1 = gradient1.gradientStops.add();
stop1.rampPoint = (bound1 - origin) / length * 100;
stop2 = gradient1.gradientStops.add();
stop2.rampPoint = (bound2 - origin) / length * 100;
... View more
‎Jun 29, 2023
11:37 AM
Then I'm not sure what you are trying to do. When you create a gradient with a script, start and end stops are automatically created. Do you want to add additional stops in between?
... View more
‎Jun 29, 2023
10:58 AM
A gradientColor has an origin property and a length property, which should allow you to control where a gradient annotator starts and ends. But the last time I tried them, neither of them worked. So you may be out of luck.
... View more
‎Jun 29, 2023
01:06 AM
Artboards are not "selected" the same way that artwork is, at least not in CS6. If they are, this property is not accessible through scripting. You can target an active artboard, but there is one active artboard at a time. Hence the artboards are targeted by selecting the items within them.
... View more
‎Jun 28, 2023
11:38 PM
1 Upvote
A bug was fixed. Try again.
... View more
‎Jun 28, 2023
03:56 PM
1 Upvote
For a column of artboards, targeted by selecting the items within the artboards: var spacing = Number(prompt("", "100"));
var doc = app.activeDocument;
// find relevant artboards and items
var artboards = [];
var collection = [];
for (var i = 0; i < doc.artboards.length; i++) {
var bounds1 = doc.artboards[i].artboardRect;
var subcollection = [];
for (var j = 0; j < doc.selection.length; j++) {
var bounds2 = doc.selection[j].geometricBounds;
if ((bounds2[2] > bounds1[0] && bounds2[0] < bounds1[2]) &&
(bounds2[3] < bounds1[1] && bounds2[1] > bounds1[3])) {
if (!elementIsInArray(doc.artboards[i], artboards)) {
artboards.push(doc.artboards[i]);
}
subcollection.push(doc.selection[j]);
}
}
if (subcollection.length > 0) {
collection.push(subcollection);
}
}
// sort relevant artboards from top to bottom
artboards.sort(function(a, b) {
return b.artboardRect[1] - a.artboardRect[1];
});
// move relevant artboards and items
for (var i = 1; i < artboards.length; i++) {
var ABR1 = artboards[i - 1].artboardRect;
var ABR2 = artboards[i].artboardRect;
var y1 = ABR2[1];
artboards[i].artboardRect = [
ABR2[0], ABR1[3] - spacing,
ABR2[2], ABR1[3] - spacing + (ABR2[3] - ABR2[1])
];
var y2 = artboards[i].artboardRect[1];
for (var j = 0; j < collection[i].length; j++) {
collection[i][j].translate(0, y2 - y1);
}
}
doc.selection = null;
function elementIsInArray(e, a) {
for (var i = 0; i < a.length; i++) {
if (a[i] == e) {
return true;
}
}
return false;
} NB. Items spanning two artboards will cause unexpected results.
... View more
‎Jun 28, 2023
08:19 AM
1 Upvote
The errors imply that the script is either not saved in the right format or not being run form the right place. The script should be saved in the Scripts folder. The Scripts folder should be somewhere like: Applications > Adobe Illustrator CC > Presets > en_GB > Scripts. The script should be saved with a .jsx (or .js) extension. Copy the above script to a plain text file and save with a .jsx extension. I have not used macs, but I understand that Apple's TextEdit, by default, will save as rich text; this is not what you want; you want plain text. The script should be run from illustrator, by going through File > Scripts. Once you have the script up and running, you can incorporate it into an action.
... View more
‎Jun 28, 2023
03:24 AM
1 Upvote
var text = app.activeDocument.textFrames;
for (var i = 0; i < text.length; i++) {
if (text[i].name == "TOTO") {
var string = text[i].contents;
string = string.replace(/ /g,"\n");
text[i].contents= string;
}
}
... View more
‎Jun 27, 2023
12:58 PM
1 Upvote
var colour2 = new CMYKColor();
colour2.cyan = 0;
colour2.magenta = 100;
colour2.yellow = 100;
colour2.black = 0;
swatch2 = app.activeDocument.swatches.add();
swatch2.color = colour2;
swatch2.name = "Red 2"
... View more
‎Jun 27, 2023
12:51 PM
1 Upvote
var colour1 = new RGBColor();
colour1.red = 250;
colour1.green = 0;
colour1.blue = 0;
swatch1 = app.activeDocument.swatches.add();
swatch1.color = colour1;
swatch1.name = "Red 1"
... View more
‎Jun 26, 2023
12:39 PM
2 Upvotes
You can save this script and run it from an action. You have not specified the units; default units are points. var w = 82;
var h = 51;
var doc = app.activeDocument;
var i = doc.artboards.getActiveArtboardIndex();
var AB = doc.artboards[i];
var ABR = AB.artboardRect;
AB.artboardRect = [
ABR[0] + ((ABR[2] - ABR[0]) / 2) - w / 2,
ABR[1] + ((ABR[3] - ABR[1]) / 2) + h / 2,
ABR[0] + ((ABR[2] - ABR[0]) / 2) - w / 2 + w,
ABR[1] + ((ABR[3] - ABR[1]) / 2) + h / 2 - h
];
... View more
‎Jun 21, 2023
12:57 PM
1 Upvote
This should also resize the stroke width proportionally and consider the visible bounds including the stroke width. I believe the math is correct, although I haven't tested it extensively. var input = 28; // desired size in points
var doc = app.activeDocument;
var target = doc.groupItems.add();
for (var i = 0; i < doc.selection.length; i++) {
doc.selection[i].moveToEnd(target);
}
var w1 = target.visibleBounds[2] - target.visibleBounds[0];
var h1 = target.visibleBounds[1] - target.visibleBounds[3];
var w2 = target.geometricBounds[2] - target.geometricBounds[0];
var h2 = target.geometricBounds[1] - target.geometricBounds[3];
var f1 = Math.min(
input / (target.width + (w1 - w2)),
input / (target.height + (h1 - h2))
);
var f2 = Math.min(
(input - ((w1 - w2) * f1)) / target.width,
(input - ((h1 - h2) * f1)) / target.height
);
target.resize(f2 * 100, f2 * 100, true, true, true, true, f1 * 100);
for (var i = target.pageItems.length - 1; i > -1; i--) {
target.pageItems[i].moveAfter(target);
}
... View more
‎Jun 20, 2023
03:55 AM
For one selected item: var input = 28; // desired size in points
var doc = app.activeDocument;
var target = doc.selection[0];
var f = Math.min(input / target.width * 100, input / target.height * 100);
target.resize(f, f); For one or more selected items: var input = 28; // desired size in points
var doc = app.activeDocument;
var target = doc.groupItems.add();
for (var i = 0; i < doc.selection.length; i++) {
doc.selection[i].moveToEnd(target);
}
var f = Math.min(input / target.width * 100, input / target.height * 100);
target.resize(f, f);
for (var i = target.pageItems.length - 1; i > -1 ; i--) {
target.pageItems[i].moveAfter(target);
} NB. Both snippets leave the question of what to do with strokes: Should stroke width resize too? Should stroke width be included in item width?
... View more
‎Jun 19, 2023
08:19 AM
Thank you.
... View more
‎Jun 15, 2023
10:19 AM
Are you able to share your script? I've not tried running Illustrator through node.js.
... View more
‎Jun 14, 2023
07:38 AM
1 Upvote
You are correct in that an asynchronous setTimeout is not possible with regular scripting.
... View more
‎Jun 07, 2023
01:50 PM
I'm not an expert either, but #include is just a way to share global variables (including function declarations) between files. To avoid reference errors, put the #includes at the top of the script. If an included file uses variables from another included file, make sure the #includes are in the logical order.
... View more
‎Jun 06, 2023
03:11 PM
1 Upvote
You can refine the logic defining a "word" so it is preceded by a space and followed by a space, comma or full stop. // select text frame
var array = ["soy", "mustard", "celery", "milk"];
var string = app.selection[0].contents;
var indices = [];
for (var i = 0; i < array.length; i++) {
indices = indices.concat(getIndices(array[i]));
}
for (var i = 0; i < indices.length; i++) {
if (string[indices[i]._1st - 1] == " " &&
(string[indices[i]._nth] == " " ||
string[indices[i]._nth] == "," ||
string[indices[i]._nth] == ".")) {
for (var j = indices[i]._1st; j < indices[i]._nth; j++) {
var attributes = app.selection[0].textRanges[j].characterAttributes;
attributes.textFont = textFonts["MyriadPro-BoldCond"];
}
}
}
function getIndices(substring) {
var indices = [];
var index = string.indexOf(substring);
while (index != -1) {
indices.push({_1st: index, _nth: index + substring.length});
index = string.indexOf(substring, index + 1);
}
return indices;
}
... View more
‎Jun 04, 2023
01:47 PM
2 Upvotes
colorGroup.addSwatch() takes a swatch as an argument, not a color, hence the error.
... View more
‎Jun 04, 2023
01:35 PM
1 Upvote
The above code manipultes strings; it does not recognise words. But you can add your own logic to define a "word". So you can add a conditional that boldens a substring only if it is followed by a space, comma or full stop. // select text frame
var array = ["soy", "mustard", "celery", "milk"];
var string = app.selection[0].contents;
var indices = [];
for (var i = 0; i < array.length; i++) {
indices = indices.concat(getIndices(array[i]));
}
for (var i = 0; i < indices.length; i++) {
if (string[indices[i]._nth] == " " ||
string[indices[i]._nth] == "," ||
string[indices[i]._nth] == ".") {
for (var j = indices[i]._1st; j < indices[i]._nth; j++) {
var attributes = app.selection[0].textRanges[j].characterAttributes;
attributes.textFont = textFonts["MyriadPro-BoldCond"];
}
}
}
function getIndices(substring) {
var indices = [];
var index = string.indexOf(substring);
while (index != -1) {
indices.push({_1st: index, _nth: index + substring.length});
index = string.indexOf(substring, index + 1);
}
return indices;
}
... View more
‎Jun 03, 2023
09:44 AM
Before running the script, draw and select the first (topmost) line. To run a script, copy and paste the code into a jsx file and save. (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. This will run the script. For more on running scripts, see here. When running the script, a prompt window will appear. In the input field, enter the number of lines and spacing between lines (in points) separated by a comma (e.g. 82, 10).
... View more
‎Jun 03, 2023
01:30 AM
Draw and select the first line. Enter the number of lines and spacing (in points) separated by a comma (e.g. 82, 10). var inputs = prompt("", "#, spacing (pt)").split(",");
var first = app.selection[0];
for (var i = 1; i < Number(inputs[0]); i++) {
var next = first.duplicate();
next.top = first.top - i * Number(inputs[1]);
}
... View more
‎Jun 02, 2023
01:05 PM
3 Upvotes
This is a quick script implementation of @Jacob Bugge's idea. // select relevant page items
var doc = app.activeDocument;
var array1 = [];
for (var i = 0; i < doc.selection.length; i++) {
array1.push(doc.selection[i]);
}
array1.sort(function (a, b) {
return a.left - b.left;
});
var bounds1 = array1[0].geometricBounds;
var x1 = bounds1[0] + ((bounds1[2] - bounds1[0]) / 2);
var array2 = [];
for (var i = 1; i < array1.length; i++) {
var bounds2 = array1[i].geometricBounds;
var x2 = bounds2[1] + ((bounds2[3] - bounds2[1]) / 2);
if (x2 > bounds1[3] && x2 < bounds1[1]) {
array2.push(array1[i]);
}
}
array2.sort(function (a, b) {
return a.left - b.left;
});
var bounds2 = array2[0].geometricBounds;
var x2 = bounds2[0] + ((bounds2[2] - bounds2[0]) / 2);
var x = x2 - x1;
var y = Number(prompt("", "", "y (points)"));
var group = doc.groupItems.add();
for (var i = 0; i < doc.selection.length; i++) {
doc.selection[i].moveToEnd(group);
}
group.resize(100 * y/x, 100 * y/x);
for (var i = group.pageItems.length - 1; i > -1 ; i--) {
group.pageItems[i].resize(100 * x/y, 100 * x/y);
group.pageItems[i].moveAfter(group);
}
... View more
‎May 25, 2023
12:41 PM
1 Upvote
var _name = "UNC";
var groups = app.activeDocument.groupItems;
for (var i = 0; i < groups.length; i++) {
if (groups[i].name == _name && groups[i].clipped == true) {
// 1 unclip
groups[i].clipped = false;
// 2 ungroup
for (var j = groups[i].pageItems.length - 1; j > -1 ; j--) {
groups[i].pageItems[j].moveAfter(groups[i]);
}
}
}
... View more
‎May 22, 2023
02:10 PM
My immediate impression is that you need to (1) parse the parenthesised string into a nested array; and (2) recursively iterate the nested array, getting the matches if they are not in succeeding inner arrays. I can do (1), but I'm unsure how to do (2). If I have the time, I'll try to think about it in the next couple of days. Hopefully, someone else might think of something I haven't.
... View more
‎May 22, 2023
02:23 AM
1 Upvote
Sticking with the same idea, this should do repeated words. // select text frame
var array = ["soy", "mustard", "celery", "milk"];
var string = app.selection[0].contents;
var indices = [];
for (var i = 0; i < array.length; i++) {
indices = indices.concat(getIndices(array[i]));
}
for (var i = 0; i < indices.length; i++) {
for (var j = indices[i]._1st; j < indices[i]._nth; j++) {
var attributes = app.selection[0].textRanges[j].characterAttributes;
attributes.textFont = textFonts["MyriadPro-BoldCond"];
}
}
function getIndices(substring) {
var indices = [];
var index = string.indexOf(substring);
while (index != -1) {
indices.push({_1st: index, _nth: index + substring.length});
index = string.indexOf(substring, index + 1);
}
return indices;
}
... View more
‎May 21, 2023
10:50 AM
I am sure there are better ways, but this is what popped into my head. It won't do repeated words though. // select text frame
var array = ["soy", "mustard", "celery", "milk"];
var string = app.selection[0].contents;
for (var i = 0; i < array.length; i++) {
var firstChar = string.search(array[i]);
var lastChar = firstChar + array[i].length;
for (var j = firstChar; j < lastChar; j++) {
var attributes = app.selection[0].textRanges[j].characterAttributes;
attributes.textFont = textFonts["MyriadPro-BoldCond"];
}
}
... View more