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

How to add Unicode arrow labels to a path while following the direction of the anchor point index

Explorer ,
Jan 13, 2025 Jan 13, 2025

Copy link to clipboard

Copied

I am in need of a script that adds arrow labels to pathItems. I would like to use Unicode characters in order to not rely on any pre-existing symbols or external configuration. I have included a sample of the code that I normally use to add labels to the bottom center of a path. I could use some help in adding the proper logic to have the Unicode arrow character point in the proper direction according to the index of the path's anchor points.

 

Screenshot 2025-01-13 at 5.40.57 PM.png

 

 

 

 

 

#target illustrator;

var idoc = app.activeDocument;

middleBottom();

//========== (Create Label and Place Horizontal Center and Bottom of Path) ==========
    function middleBottom() {
        var labelMargin = 5;
        var label = idoc.layers.getByName('Layer 1').textFrames.add();
        label.name = "Path Label";
        label.contents = "\u2190";
        label.opacity = 25.0;
        label.textRange.characterAttributes.textFont = textFonts.getByName('ArialMT');
        label.textRange.characterAttributes.size = 12;
        var refBnds = idoc.layers.getByName('Layer 1').pathItems[0].geometricBounds;
        var objBnds = idoc.layers.getByName('Layer 1').pathItems[0];
        var tg = idoc.layers.getByName('Layer 1').textFrames.getByName('Path Label');
        var ct = (refBnds[0] - (tg.width / 2)) + (objBnds.width / 2); // center
        var md = refBnds[1] - (tg.height - labelMargin); //bottom
        tg.position = [ct, md];
        idoc.selection = null;
    }

 

 

 

 

 

 

TOPICS
How-to , Scripting

Views

62

Translate

Translate

Report

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
no replies

Have something to add?

Join the conversation
Adobe