Import vector data into illustrator


Question

I have a program that generates thousands of vector points (just coordinates), the format is not fixed, but it could be something like this:

(2.4785|77.01)
(78.8|9.88)
(45.33|0.2)

I am able to format/convert this coordinates any way necessary.

My question is: How can I import these coordinate data into Illustrator as vector points, so I can work with them properly (give them a stroke, scale them etc.).

The result could be something like this, but this is pixel data. I want something similar to that, only as a vector.

Edit: Each coordinate should result in one dot/circle being rendered in Illustrator, so maybe each coordinate should be made into a line with identical beginning and end in illustrator?

It is a little hard to see in the screenshot, but the lines actually consist of many individual dots which are not always touching.

I generated the dot coordinates with a little java code, if anyone is interested in it, just PM me.

Solution: Jackson Hyde suggested SVG as a possible format in his answer, which turns out to work perfectly. I just generate this SVG file and then import it into Illustrator. There I can select all points and add a stroke and do some other fancy stuff.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events"
     version="1.1" baseProfile="full"
     width="20px" height="20px">

<line x1="15.23" y1="2.25" x2="15.23" y2="2.25" />
<line x1="8.1234" y1="7.85" x2="8.1234" y2="7.85" />
[...]

</svg>
1
5
6/24/2014 8:39:00 PM

Accepted Answer

As a alternate to SVG you could generate a EPS file instead, its less verbose than SVG and has less caveats. Here's a quick intro:

http://paulbourke.net/dataformats/postscript/

Generating EPS

EPS is a framed form of postscript meant to be included in other postscript jobs/desktop publishing applications. To handle this it needs a header to define the bounding box etc. The header would look as follows:

%!PS-Adobe-3.0 EPSF-3.0 
%%BoundingBox: 0 0 100 100
%%Title: Demo for GD.SE
%%Creator: Janne Ojala 
%%CreationDate:  2014-06-23
%%EndComments

This info is strictly not necessary for illustrator, as illustrator is a postscript engine. Nevertheless, you may want to include it so the file can be used as is without illustrator. Using a header also makes it easier to use in illustrator. The Bounding box defines the size of your artwork, coordinates lower left, upper right.

Next you need to handle your data for ease you may want to add a simple routine for drawing a single point:

/P {newpath 1 0 360 arc fill} def %draw circle with radius of 1

Now all you need is to define each point as follows:

15.23 2.25 P
8.1234 7.85 P
...

Finally your eps needs a end marker like this

%%EOF

Done. In general EPS is one of the easiest formats to generate, you could actually omit all the P calls by iterating over an array, file or binary data but ill leave this as it is for time being.

Workflow

Here is a trick that you can use for visualizing the data while your developing the EPS file. After all something can go wrong and its useful to have some feedback:

  • Place the EPS file in Illustrator

Now each time you edit the EPS file and jump back to illustrator it will ask you you want to update. If you click yes, you get instant feedback, and if you have an error you get a blank image. You can expand it when your ready.

Other resources

  1. Online postscript 2 reference
  2. Ghostscript a software postscript engine, for debugging, conversion to PDF etc.

Alternate functions in EPS

The function could be replaced by:

1 setlinecap
/P {newpath moveto 0 0 rlineto stroke} def

for the same kind of 0 size line approach. you can add a:

1 -1 scale 

and use negative bounding box for top left measurement directions.


Other formats

In addition to EPS and SVG another easy transfer format is DXF. The DXF spec can be found here:

PDF is also relatively easy to generate in this specific case. Tough the easiest way would be to distill the EPS with acrobat or ghost script. Generating the data tables and check-sums is a bit of extra work but other than that its almost as straightforward as generating a EPS file. PDF Spec can be found here:

A manually crafted pdf sample, this uses the same idea as described in the the EPS and SVG answers containing the 2 demo points. Search for % graphics here for the relevant section (if you paste this in a text file that has PDF set as extension it should just work).

The problem with PDF is is generating the lengths of the sections for the XREF table which is a bit painful to do by hand. This is why I avoid PDF in quick cases like this. Granted, adobe will ignore the tags if the PDF is just one page. So ignoring those you may generate a technically incorrect PDF file that still just works. Fun example exploiting this phenomena can be found here.

7
5/23/2017 12:40:00 PM

The easiest way I can think of is formatting your application to output an SVG Formatted Image. Illustrator can work with SVG graphics in a number of ways.

It's worth noting that in your image you are displaying more than just a cloud of points. It looks like your points have either been transformed over time (to give a 'trail' effect) or are connected to create paths. Just outputting a cloud of coordinates will not replicate this effect, you'll need to work with the SVG coordinate spec (coordinate transforms in particular).


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow


Website under construction!!!
^