Skip to main content
November 7, 2011
Question

Generating connected rounded rectangles

  • November 7, 2011
  • 2 replies
  • 662 views

Hi there,

i want to generate a Illustrator file and then work on the result manually. I have alot (hundreds) of strings which i want to be placed in rounded rectangles and then some of them are connected by paths with arrowheads. Let me show you a small example done by hand:

What i already have, is the code to generate the rectangles and the string. What i couldnt find up to now, is a possibility to fix a path to the rectangles. The problem is that i dont know the final position of the rectangle in advance, i have to place it by hand. So the path should move with the rectangle.

Here is what i do up to now:

var docRef = app.activeDocument;

var layer = app.activeDocument.layers.add();

    var black = new CMYKColor();

    black.black = 100.0;

    var white = new CMYKColor();

    white.black = 0.0;

var newGroup = docRef.groupItems.add();

newGroup.name = "myGroup";

newGroup.move( docRef, ElementPlacement.PLACEATEND);

var rndRect = newGroup.pathItems.roundedRectangle( 637.5, 87.5, 185.0, 18.0, 3.0,3.0);

rndRect.position = Array(100,70.0);

rndRect.fillColor = white;

rndRect.strokeColor = black;

var pathTextRef = newGroup.textFrames.add();

pathTextRef.contents = "parabolicAnt.carrierFrequency";

pathTextRef.selected = true;

pathTextRef.position = Array(50,72.0);

So, any hints appreciated.

Thanks, Joe

PS. a minor question in this context: How can i center the string in the rounded rectangle?

This topic has been closed for replies.

2 replies

Participant
November 7, 2011

I have one question, why would you use a script for a task like that, can't you just do it manually creating a graphic style for a text in a rounded frame or something like that?

November 8, 2011

i have a huge amount of data and i dont even want to type all the strings into illustrator. maybe a graphic style with a rounded frame and an anchor point attached would be a possibility? i have only rudimental knowledge on the GUI features of Illustrator too, so maybe a manual solution would enable me to find out the script by myself.

Thanks anyways for any hints!

Inspiring
November 7, 2011

At a quick glance… Use the same bounding box as you have given the rounded rectangle and create a boxed text frame not a point text frame… You should then be able to centre OK… If you've grouped them they will move together…