Copy link to clipboard
Copied
Give I have the document with multiple text frames (orange with text) and a number of lines and small shapes (black circles or orange small squares:
Some of the rules are:
There is a brute force solution to this problem where I create an array of text frames, an array of point objects (for the lines) and an array of shapes. Sort each array by x coordinates and y coordinates. Traverse the points array (line start and end points) and see what objects/text frames contain the points.
Is there a more elegant solution where I can leverage the selection engine.
Copy link to clipboard
Copied
I would do it like this:
If a symbol needs to be connected to a text frame with a keyline, name the symbol on the Layers panel, using the text frame's content for the name.
Then cycle through the text frames. For each text frame, if there is a named symbol, draw a keyline on the fly from the text frame to the symbol.
for (i = 0; i < frames.length; i++) {
if (myDoc.pageItems.item(frames.contents).isValid) {
// Draw a keyline between the frame and the symbol
}
}
Peter
Copy link to clipboard
Copied
I don't see any other approach except for "brute force". You can fine-tune it a bit, however:
1) function isConnected(line,symbolOrTextFrame){return Boolean}
2) arrayOfLines
3) arrayOfTextFramesAndSymbols
iterate through the lines array, for each find the connected object, then remove the found connected object form it's array.