Skip navigation
TheRealUpWorks
Currently Being Moderated

How can I create poly coords from an AI file?

Jul 25, 2012 2:06 PM

Tags: #illustrator #poly-coords #image-map

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

 
Replies
  • Currently Being Moderated
    Jul 25, 2012 11:24 PM   in reply to TheRealUpWorks

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2012 10:28 AM   in reply to TheRealUpWorks

    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.)

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2012 11:54 AM   in reply to TheRealUpWorks

    This seems to work from simple tests.

     

    Screen shot 2012-07-26 at 11.51.53 AM.png

     

     

    #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();
    
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2012 2:03 PM   in reply to TheRealUpWorks

    Ai uses points as its internal referencing system and the 0,0 point is at the upper left of the page. A point is 1/72 of an inch (from Postscript page description language).

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2012 2:40 PM   in reply to TheRealUpWorks

    As far as AI is concerned thay are the same. How are you determining the x and y your are describing?

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2012 3:11 PM   in reply to TheRealUpWorks

    No, I mean your pixel x-y.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2012 4:34 PM   in reply to TheRealUpWorks

    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?

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2012 6:42 PM   in reply to TheRealUpWorks

    you should get something like this, try it with a simple shape, to see how it works.

    coords.gif

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 27, 2012 9:54 AM   in reply to TheRealUpWorks

    the script shows "global" position, you probably have "Artboard Rulers". Right-Click on the Rulers to make sure.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 27, 2012 10:08 AM   in reply to TheRealUpWorks

    mmh...create a new document and add a simple shape to see if it works, and if it does check the rulers if they're still greyed out.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 27, 2012 10:27 AM   in reply to TheRealUpWorks

    not that I know of, if you change to Global, does it work as expected?

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 27, 2012 11:08 AM   in reply to TheRealUpWorks

    cool, you're welcome

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points