Copy link to clipboard
Copied
I do have random number of texts (can be 500+), in a randomly named layer, randomly placed on the artboard. That needs to be converted to circles with the coresponding names.
Endgoal Example:
Select all texts in the layer run the script and the text to be converted into circles with the coresponding text names. Circles should be placed in the center of the textboxs. It doesnt mater if text names are lost as long as circles appear in textbox center with the coresponding name.
Circle propertys:
1. Should be <paths>
2. Colour code: AAC945
3. Size: 15x15
1 Correct answer
It's easily done. You did mention it in your first post, but I missed it. (Also, I overthought things in the first script, because I didn't know both point and area text had the same left, top, width and height properties.)
// select text frames
var w = h = 15;
var doc = app.activeDocument;
var items = doc.selection;
for (var i = 0; i < items.length; i++) {
var cX = items[i].left + (items[i].width / 2);
var cY = items[i].top - (items[i].height / 2);
var path2 = doc.pathItem
...
Explore related tutorials & articles
Copy link to clipboard
Copied
1. What units is the size of the circle?
2. Is the text point type or area type (or either)?
Copy link to clipboard
Copied
1. Hope this will help with the circle.
2. Either.
Copy link to clipboard
Copied
// select text frames
var w = h = 15;
var doc = app.activeDocument;
var items = doc.selection;
for (var i = 0; i < items.length; i++) {
if (items[i].kind == TextType.POINTTEXT) {
temp = items[i].duplicate()
var path1 = temp.createOutline();
var cX = path1.left + (path1.width / 2);
var cY = path1.top - (path1.height / 2);
path1.remove();
} else if (items[i].kind == TextType.AREATEXT) {
var path1 = items[i].textPath;
var cX = path1.left + (path1.width / 2);
var cY = path1.top - (path1.height / 2);
}
var path2 = doc.pathItems.ellipse(cY + h / 2, cX - w / 2, w, h)
path2.zOrder(ZOrderMethod.SENDTOBACK);
var color1 = new RGBColor;
color1.red = 170;
color1.green = 201;
color1.blue = 69;
path2.fillColor = color1;
}
Copy link to clipboard
Copied
At this point the script does the circles. I might have not explane it properly excause me if this is the case.
If I convert the text: Name 15, Name 25, Name 11, etc. to circles (as the script does). I want the circle to have the corresponding names of the texts they were converted from.
If top right left circle was converted from textbox: Name 15, I want circle name to become Name 15.
Do you think this is possible?
Really apreciate your time. You are life saver. Thank you for your time! 🙂
Copy link to clipboard
Copied
It's easily done. You did mention it in your first post, but I missed it. (Also, I overthought things in the first script, because I didn't know both point and area text had the same left, top, width and height properties.)
// select text frames
var w = h = 15;
var doc = app.activeDocument;
var items = doc.selection;
for (var i = 0; i < items.length; i++) {
var cX = items[i].left + (items[i].width / 2);
var cY = items[i].top - (items[i].height / 2);
var path2 = doc.pathItems.ellipse(cY + h / 2, cX - w / 2, w, h)
path2.zOrder(ZOrderMethod.SENDTOBACK);
var color1 = new RGBColor;
color1.red = 170;
color1.green = 201;
color1.blue = 69;
path2.fillColor = color1;
path2.name = items[i].contents;
}
Copy link to clipboard
Copied
Amazing! It does the job perfectly! 🙂

