Eduard Buta
Participant
Eduard Buta
Participant
Activity
‎Jan 09, 2025
03:00 AM
Hello community, As the title suggests, I was wondering if it's possible to somehow use (even potentially through scripting) the Plus Lighter and Plus Darker blending modes in Adobe Illustrator. They seem to be available in Figma and other design software, but no trace of them in the Adobe Suite. Perhaps their results could even be replicated somehow? Curious what your thoughts are on the matter.
... View more
‎Aug 20, 2024
04:26 AM
Thank you very much. This helped me get to the bottom of my problem. Much appreciated!
... View more
‎Aug 20, 2024
03:14 AM
Hey, @m1b . I found a bug in my existing logic, and I was wondering if you know how could I detect the actual height of the letterforms in a text object via scripting? The object.height is unreliable for my use case, since it picks up the text's leading spaces.
... View more
‎Aug 19, 2024
09:13 AM
Thank you for the resources, @hhas01 Albeit, these might be a bit overkill for my simple need at the moment. I'm also pretty much struggling with ExtendScript as it is, so I doubt I'd be able to understand these. I managed to do what I wanted with what the API already offers and a bit of creative thinking on the side. Your answer is much appreciated either way!
... View more
‎Aug 19, 2024
06:39 AM
Thank you for your detailed response, @m1b You said the following: "You could potentially analyse the text metrics after the change to see if that particular text changed and that would prove that the stylistic set did exist in the font". I've already thought about this approach, and I think that's what I'm going to do, since it would most likely work in my use case. I also wanted to let you know that I definitely did not know about binary coded decimal. So far I've got my code to a certain point, but I'm sure this will help me polish it further. Thank you very much!
... View more
‎Aug 19, 2024
02:35 AM
Hello community, I am working on a small script that has to do with toggling OpenType style sets. I've figured out how to actually turn on a specific stylistic set using this syntax: textVariable.textRange.characterAttributes.stylisticSets = STYLYSTIC_SET_NUMBER; The problem is that, by default, all fonts that support stylistic sets have 20 such sets defined in the UI, with most of them grayed out if not actually available. However, when I try to loop through the available Stylistic Set options of a selected text using a for loop, even the grayed out ones are picked up. Do you know if there is a way to validate the actual available style sets so that I can count them properly?
... View more
‎Apr 06, 2024
02:04 AM
Thank you very much. Your solution wasn't exactly what I was looking for, but I suspect it's because I didn't explain my needs well enough. Regardless, I was able to figure out how the coordinate system works now using your simplified approach, and I managed to get it working for my use-case. I'll paste the code below for future reference if someone needs something like this. Thank you again! // Top-left corner
drawMark(x1 + bleedPoints, y1, lengthPoints, true); // Vertical
drawMark(x1 - lengthPoints, y1 - bleedPoints, lengthPoints, false); // Horizontal
// Top-right corner
drawMark(x2 - bleedPoints, y1, lengthPoints, true); // Vertical
drawMark(x2, y1 - bleedPoints, lengthPoints, false); // Horizontal
// Bottom-left corner
drawMark(x1 + bleedPoints, y2 - lengthPoints, lengthPoints, true); // Vertical
drawMark(x1 - lengthPoints, y2 + bleedPoints, lengthPoints, false); // Horizontal
// Bottom-right corner
drawMark(x2 - bleedPoints, y2 - lengthPoints, lengthPoints, true); // Vertical
drawMark(x2, y2 + bleedPoints, lengthPoints, false); // Horizontal
... View more
‎Apr 05, 2024
08:26 AM
Hey guys. I'm hoping someone can help me out here. I'm trying to create a small script that takes a length and bleed value (for offset calculation) and creates trim marks in the corners of all user-selected objects based on those values. I'm really having trouble positioning these trim marks properly, as Illustrator's coordinate system is the most unintuitive thing ever. Especially since length has to be taken into account as well. I know there's a very comprehensive script out there that does this, but it's huge and I'm unable to understand it deeply enough to extract this functionality from it. I need this trim mark creation part for another script I'm working on. Hoping some of you might have some tips as to how to approach positioning these things. Thanks! Pasting what I have so far here: #target illustrator
function createTrimMarks(bleed, markLength) {
if (app.documents.length > 0 && app.selection.length > 0) {
var bleedPoints = bleed * 2.83464567; // Convert mm to points
var lengthPoints = markLength * 2.83464567; // Convert mm to points
var doc = app.activeDocument;
for (var i = 0; i < app.selection.length; i++) {
var item = app.selection[i];
var bounds = item.geometricBounds; // [x1, y1, x2, y2]
var x1 = bounds[0], y1 = bounds[1], x2 = bounds[2], y2 = bounds[3];
// Calculate offset positions
var offsetX = x1 - bleedPoints;
var offsetY = y1 - bleedPoints;
var endX = x2 + bleedPoints;
var endY = y2 + bleedPoints;
// Top-left corner
drawMark(offsetX, offsetY, lengthPoints, true); // Vertical
drawMark(offsetX, offsetY, lengthPoints, false); // Horizontal
// Top-right corner
drawMark(endX, offsetY, lengthPoints, true); // Vertical
drawMark(endX - lengthPoints, offsetY, lengthPoints, false); // Horizontal
// Bottom-left corner
drawMark(offsetX, endY - lengthPoints, lengthPoints, true); // Vertical
drawMark(offsetX, endY, lengthPoints, false); // Horizontal
// Bottom-right corner
drawMark(endX, endY - lengthPoints, lengthPoints, true); // Vertical
drawMark(endX - lengthPoints, endY, lengthPoints, false); // Horizontal
}
} else {
alert("No document open or nothing selected.");
}
}
function drawMark(startX, startY, length, isVertical) {
var doc = app.activeDocument;
var path = doc.pathItems.add();
path.setEntirePath([
[startX, startY],
isVertical ? [startX, startY + length] : [startX + length, startY]
]);
path.stroked = true;
path.strokeWidth = 0.25;
path.strokeColor = new CMYKColor();
path.strokeColor.black = 100;
path.filled = false;
}
function showDialog() {
var dialog = new Window('dialog', 'Trim Marks Parameters');
dialog.orientation = 'column';
dialog.alignChildren = 'left';
var bleedGroup = dialog.add('group');
bleedGroup.add('statictext', undefined, 'Bleed Size (mm):');
var bleedInput = bleedGroup.add('edittext', undefined, '3');
bleedInput.characters = 5;
var lengthGroup = dialog.add('group');
lengthGroup.add('statictext', undefined, 'Mark Length (mm):');
var lengthInput = lengthGroup.add('edittext', undefined, '5');
lengthInput.characters = 5;
var buttonGroup = dialog.add('group');
buttonGroup.alignment = 'right';
var okButton = buttonGroup.add('button', undefined, 'OK', { name: 'ok' });
var cancelButton = buttonGroup.add('button', undefined, 'Cancel', { name: 'cancel' });
okButton.onClick = function() {
var bleed = parseFloat(bleedInput.text);
var markLength = parseFloat(lengthInput.text);
if (isNaN(bleed) || isNaN(markLength)) {
alert('Both bleed size and mark length must be numbers.');
return;
}
dialog.close();
createTrimMarks(bleed, markLength);
};
dialog.show();
}
showDialog();
... View more
‎Nov 17, 2023
07:49 AM
I know there are plugins that do this, but thanks for the recommendation anyway. My plan is to integrate this script into something a bit more complex, that fits a specific use case I have in mind. So I need to keep looking for solutions to do this via scripting.
... View more
‎Nov 17, 2023
12:04 AM
Thank you for your response, Jacob. To clarify a few things. I only used the term "perfect circle" to make it clear that I'm trying to figure out if a path can form a circle, not just any elliptical shape. Also, I'm not trying to fit a path into a circle, I'm trying to see if an existing path, if extended given its curvature, can form a circle. I am not sure if the approach in the article is even right for the task at hand, but it was the best I could find as a starting point for my problem. Sergey's answer below does a pretty good job of visually demonstrating what I'm trying to do.
... View more
‎Nov 17, 2023
12:00 AM
Indeed. However, I was first trying to get it working for this particular use case you described, and figure out if it can then be tweaked for the more non-straightforward cases. I was pretty much counting on this part: Q. What if we divide the circle into more than four arcs? A. We can achieve an arbitrarily-good approximation that way. Even a chord approximation can become arbitrarily good if the circle is subdivided into enough arcs.
... View more
‎Nov 16, 2023
11:57 PM
Yes, @Sergey Osokin . This is pretty much what I meant to do! Thanks for the great visual example!
... View more
‎Nov 16, 2023
12:31 PM
3 Upvotes
Hello community, I've been trying to use scripting to find out if a user-selected curved path (formed from two anchor points) can be part of a perfect circle, and if so, draw the circle with the appropriate circumference on the artboard. It's a pretty complex topic that (in my mind) requires some mathematical knowledge to figure out. I've found the following article that does a pretty good job explaining how a circle can be approximated based on a cubic Bezier curve. However, I got stuck pretty early on because I didn't know exactly how to translate the two anchor point path I have on the screen into the four control points that form a cubic Bezier curve. Especially when it comes to referencing such coordinates via scripting. Hoping that some of your bright minds might want to jump in on the challenge!
... View more
‎Mar 12, 2023
09:21 AM
Hey, @CarlosCanto! Any chance this kind of logic would work for dividing multi-line text into separate lines, row by row? Couldn't find anything on the forums to help me in that regard...
... View more
‎Mar 09, 2023
11:00 AM
I'll try to explain it a little bit better. For example, when I'm working with logo files, I create a whole lot of variations. Each logo option is added to a document, and each one is wrapped in a group. Then, I run a script that creates artboards around every group in the document, so now I have a bunch of artboards around every one of my logo options. Problem is, all those options are still on one layer in the layers panel, and I'd prefer them to be separate, each with its own layer, so I can correctly categorize them and rename them. That's when I run a script that loops through all artboards, detects the items within each artboard, and moves them to their own layers. So now I have a bunch of artboards and a bunch of corresponding layers, right? I now finally run another script that sorts artboards based on their viewport position, from top left to bottom. So I suddenly have my artboards ordered the way I want them to, based on the position I see on the screen. However, this script doesn't also sort their corresponding layers. So while my artboards are neatly sorted from 1 to X, my layers are all pretty much randomly ordered, based on how the script initially created them. I'd like a way to sort these layers as well, based on their corresponding artboard number. Hope this made better sense? Let me know!
... View more
‎Mar 03, 2023
06:26 AM
Any chance you could paste a code snippet that does what you mentioned here? It's hard for a non-coder to visualize how this would look like in code.
... View more
‎Feb 28, 2023
11:31 AM
So in this case, there's absolutely no way to reference these layers? For example, I was thinking of creating another script that basically reorders all my layers (in the layers panel) based on their corresponding artboard number. Would something like that be doable?
... View more
‎Feb 28, 2023
08:52 AM
You're right. My apologies for not including code. Here is such a quick code snippet, that's supposed to change the name of selected top-level layers based on a string the user inputs: // Define variables
var doc = app.activeDocument;
var selection = doc.selection;
// Check if there is a selection
if (selection.length == 0) {
// If no selection, show an error message
alert("No selection was made. Please select one or more items to rename.");
} else {
// If there is a selection, show a dialog window to input the new name
var newName = prompt("Enter the new name:", "");
if (newName != null) {
// Loop through the selection and rename each item
for (var i = 0; i < selection.length; i++) {
selection[i].name = newName;
}
}
} Let me know if you spot any mistake that could help me out in my case. Thank you very much!
... View more
‎Feb 28, 2023
06:22 AM
Hello, community. For a while now, I've been using ChatGPT to help me do something I wasn't able before - write the Illustrator scripts I need to improve the efficiency of my workflows. That being said, I always run across one problem that I wasn't able to fix with my limited coding knowledge. I cannot figure out how to reference top-level layers in illustrator. For example, I've been trying to create a script that renames all selected layers, based on a user's input string. However, when I run the script, it doesn't actually rename the selected layers, but the first item that is held within each of those layers. It's driving me crazy. Looking forward to hearing your thoughts on this. Thank you very much for your time!
... View more
‎Dec 03, 2022
02:21 AM
Thank you for the great script, @renél80416020 ! I am curious - can this be modified to work with this script right here? The extended controls for this script's sizing between items and number of iterations, plus your scaling options would yield the absolute best results, but I am nowhere close to being able to code these together myself.
... View more
‎Nov 13, 2022
11:25 PM
Hey, @Inventsable! Have you had the chance to take a closer look at this?
... View more
‎Oct 31, 2022
12:40 AM
Anytime works for me. I'm just grateful that you're willing to help me out for my specific use case. Thanks!
... View more
‎Oct 28, 2022
07:30 AM
Hello, comunity. A while back, I have found the script below on this forum, courtesy of @Inventsable. It's function is to batch rename layers based on replacing an existing string with another input string. I have modified this script a little bit for personal use, making sure that the string I want to replace is captured through a prompt inside Illustrator, as oposed to the original which was hard-coded. I'm not much of a coder, so my question now is this: Is it possible to modify this script in a way that will allow it to work only on layers that have been selected? Looking forward to hearing your thoughts! // You can change these settings:
var settings = {
// Should the script guess the name for unnamed items like <Group>, <Path>, etc:
replaceGenerics: true,
// Should the script replace "HELLO" when findText is "Hello":
caseSensitive: false
}
var findText = Window.prompt ('Enter Search String', 'text 1', 'Find/Replace Layer Names');
if (findText == null) {
alert ('Cancelled by user');
}
var replaceText = Window.prompt ('Enter Replace String', 'text 2', 'Find/Replace Layer Names');
if (replaceText == null) {
alert ('Cancelled by user');
}
/**
*
* Don't edit below unless you know what you're doing
*
*/
Array.prototype.forEach = function (callback) {
for (var i = 0; i < this.length; i++) callback(this[i], i, this);
};
function get(type, parent) {
if (arguments.length == 1 || !parent) parent = app.activeDocument;
var result = [];
if (!parent[type]) return [];
for (var i = 0; i < parent[type].length; i++) {
result.push(parent[type][i]);
if (parent[type][i][type])
result = [].concat(result, get(type, parent[type][i]));
}
return result || [];
}
function findReplace(find, replace, options) {
var layers = get('layers');
var pageItems = get('pageItems');
var list = [].concat(layers, pageItems);
var findRX = new RegExp(getEscapedRXString(find), !options.caseSensitive ? 'i' : null)
list.forEach(function (item) {
if (item.name.length)
item.name = item.name.replace(findRX, replace)
else
item.name = options.replaceGenerics && findRX.test(item.typename)
? item.typename.replace(/item/i, '').replace(findRX, replace)
: item.name
})
}
function getEscapedRXString(string) {
return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');
}
findReplace(findText, replaceText, settings)
... View more
‎Sep 01, 2022
04:14 AM
Hello, community. I ran into this issue today and wondered whether such a script exists or if anyone could help me out. I am trying to do this: Let's say I have a top-level layer that contains a bunch of nested layers, each with its specific name. What I am trying to do now is select these individual nested layers, and upon running a script, unnest and create top-level layers for each one, while also giving these new top layers the original layer's name. I have found this built-in method of doing something similar. However, this still doesn't solve the top-level layer renaming issue, as it creates top-level layers named "Layer 1", "Layer 2", etc. My concern is mainly focused on not having to rename dozens of layers again. Looking forward to hearing your scripting wisdom. Thank you very much!
... View more
‎Aug 25, 2022
12:12 AM
1 Upvote
Thank you very much, @femkeblanco . This absolutely did the trick.
... View more
‎Aug 25, 2022
12:10 AM
Hi, Dilliam. Unfortunately, this didn't seem to work for me out of the bat, probably due to its dependencies on other libraries. That makes it a bit harder for me to manage, so I am looking for a much simpler solution like @femkeblanco 's above. I'm sure this will come in handy for someone else browsing the forum for a similar problem. Thank you!! P.S. Will take a closer look at your utility when my time allows me to play around with it a bit. It sounds truly amazing. Thanks for all the great work you're putting out there!
... View more
‎Aug 25, 2022
12:08 AM
Thank you, Kurt. This will be definitely most useful to someone. However, I'm more of a script guy, since I'm using a script manager plugin that allows me to create GUI items out of them. I appreciate it nonetheless!
... View more
‎Aug 24, 2022
12:52 AM
Hello, community. I've run across this issue in my workflow, and I am pretty sure this can be solved via scripting. I am looking for a script that can add guides (both horizontal and vertical) to the centerpoint of a selected object. By centerpoint, I understand the intersection of the middle points for both the object's width and height. Looking forward to hearing back whether such a solution already exists (I've tried finding one, without any luck) or can be done. Thank you!
... View more
‎Aug 18, 2022
10:21 AM
Thank you very much for taking the time to answer this. Was well worth a shot asking. Too bad it can't be done yet.
... View more
‎Aug 18, 2022
04:45 AM
Hello, community. I was wondering if it's possible to create a script that would handle toggling Trim View on and off when run. I've run across the frequent need to turn Trim View on and off to preview my artboards in a more isolated environment, and I'd like to turn such a script into a button via my Scripts Manager to speed up my workflow. I'd appreciate any guidance on this! Thanks!
... View more