Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Can someone share script that converting texts to circles (Path)

Explorer ,
Apr 14, 2022 Apr 14, 2022

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.

Converting Text to Circles (Path) 1.JPGexpand image

 

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.

Converting Text to Circles (Path) 3.JPGexpand image

 

Circle propertys:

1. Should be <paths>

2. Colour code: AAC945

3. Size: 15x15

Converting Text to Circles (Path) 3.JPGexpand image

TOPICS
Scripting
319
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Apr 15, 2022 Apr 15, 2022

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
...
Translate
Adobe
Guide ,
Apr 15, 2022 Apr 15, 2022

1.  What units is the size of the circle? 

2.  Is the text point type or area type (or either)? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 15, 2022 Apr 15, 2022

1. Hope this will help with the circle.

DS_0-1650015802913.pngexpand image

2. Either.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 15, 2022 Apr 15, 2022
// 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;
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 15, 2022 Apr 15, 2022

At this point the script does the circles. I might have not explane it properly excause me if this is the case.

DS_0-1650018049337.pngexpand image

 

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.

DS_1-1650018323512.pngexpand image

Do you think this is possible?


Really apreciate your time. You are life saver. Thank you for your time! 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 15, 2022 Apr 15, 2022

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;
}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 15, 2022 Apr 15, 2022
LATEST

Amazing! It does the job perfectly! 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines