I have an ai file containing a U.S. map with each state on its own layer and path. I need to be able to create the poly coords for each state for use in an image map.
Is this possible and how? Thank you in advance for assistance.
m
Image maps for web design are handled inside the HTML code. That being so, nobody would use genuine detailed vector data for it. Simply re-trace the contours with a few points in Dreamweaver or whatever web design tool you use. If that's nort good enough, an SVG with interaction might also work.
Mylenium
Thank you for the reply. Understood, however, I am asking if there is a tool that can convert the paths of an intricate state border to poly coords e.g { 110,2, 110,58......} as they relate to my image which is a smart object from illustrator. I am hoping I do not have to create these cooridinates manually, right?
http://forums.adobe.com/message/4388468#4388468
(There should be a longer example floating around this forum, perhaps someone else remembers the crucial magic phrase to google it.)
This seems to work from simple tests.
#target illustrator
var textFile = File('~/Desktop/AI.txt');
var idoc = app.activeDocument;
var idocText = '';
var layers = idoc.layers;
for (j=0; j<layers.length; j++) {
var ipath = layers[j].pathItems[0];
var itext = idoc.layers[j].textFrames.add();
var pp = [];
for (i=0; i<ipath.pathPoints.length; i++) {
pp.push(ipath.pathPoints[i].anchor);
}
itext.contents = layers[j].name + ":" + ("\r") + pp.join ("\r");
pp = null;
}
for (var i = 0; i < idoc.textFrames.length; i++)
{
idocText += idoc.textFrames[i].contents + '\r';
}
textFile.open('e');
textFile.write(docText);
textFile.close();
idoc.textFrames.removeAll();
Larry, thank you for your response.
I am using this script and selected one state at a time for testing:
var idoc = app.activeDocument;
var sel = idoc.selection;
for (j=0; j<sel.length; j++) {
var ipath = sel[j];
var itext = idoc.textFrames.add();
var pp = [];
for (i=0; i<ipath.pathPoints.length; i++) {
pp.push(ipath.pathPoints[i].anchor);
}
itext.contents = pp.join ("\r");
itext.left = ipath.left + ipath.width + 2;
itext.top = ipath.top;
pp = null;
}
That gets me output like this:
-530.1064453125,119.90087890625
-527.20166015625,119.49658203125
-522.2373046875,118.70068359375
<snip>
The only problem is that that first coordinate -530.1064453125 is really at pixel point location x 243.15, y 79.91. What is -530.nnnnn?
The number you see are given in a coordinate system which reads from bottom left (the old way); the numbers from the script are from the top left. So for the corresponding you have to add a minus number equal to the height of your artboard. Makes lots of sense, right?
you should get something like this, try it with a simple shape, to see how it works.
look at the second coords (0, -67) and note the position of the 9-point Ref point in the Transform panel, it gives you X: 0 pt, Y: 67 pt. As Larry mentioned, the sign difference is due to a change in the system from CS4 to CS5, I did not write logic to deal with it at that time.
I sent the file to my personal mac, work is PC, and opened the file. When I right click on the rulers it has an option 'Change to Global Rulers' but left it alone. When I run the script, I get the same results as on the PC. (-530.106....)
This makes me want to ask, could the layer or layers have a setting for the artboard?
Got it! ![]()
In this order:
I went into preferences, changed units to pixels, general was set to points.
Clicked on Artboard, set the reference point to the top left.
Set the ruler starting point? to the edge of the top left corner of artboard.
Ran the script and bang! The correct, or rather, preferred output has been achieved.
Thank you:
North America
Europe, Middle East and Africa
Asia Pacific