Illustrator Import
Posted by Branton Davis on Sep 21, 2006
I just downloaded NodeBox and am getting started, but can't seem to figure out how to import Illustrator files. I've tried searching the help as well as this site and can't find anything except where it says it's possible.
Can anyone lead me in the right direction?
Thanks,
Branton
Posted by Branton Davis on Sep 22, 2006
Thanks for the response, Tom.
Is there any way to import the vector data from Illustrator? For example, I've drawn something in Illustrator and would like to get something from that to put in my code and manipulate, such as the bezier curve example:
autoclosepath(close=False)
beginpath(100,100)
curveto(150, 100, 200, 200, 50, 400)
endpath()
Perhaps digging through the EPS file format would allow me to find this data?
Thanks again!
Posted by tom De Smedt on Sep 25, 2006
Hi Branton,
I think going through EPS would be a frustrating experience.
The image() command really imports all of the vector data, it's just not editable that way... I believe you want access to each individual vector point? An easy solution I used in the past is to put the vector drawing in a font using FontLab or something and then apply the font in NodeBox. Then you can use the textpath() command. Pixie was made that way.
Another interesting thing is SVG. SVG is a more-or-less structured description of vector drawings. Since it's based on XML, it very easy to parse in a NodeBox script:
import xml.dom.minidom as parser
dom = parser.parse("stuff.svg")
paths = dom.getElementsByTagName("path")
for path in paths:
d = path.getAttribute("d")
d is a string containing all the coordinate information of a path. So basically with a bit of string manipulation you could convert d to curveto's and lineto's. I made a small proof-of-concept here:
http://nodebox.net/code/data/media/svgpathparser.zip
It doesn't catch all of the mess stored in d but the principle is there. If you want to expand this script you're going to need this as well:
http://www.w3.org/TR/SVG/paths.html
It's a description of every parameter in the d string.
Have fun!
Posted by Branton Davis on Sep 25, 2006
Tom,
Thanks so much! I was already reading through the SVG specifications and attempting to parse it myself, but the xml parsing is certainly better :) I shall continue with your parser and post what I end up with.
Thanks again for such a wonderful program. I'm using it for my Math & Art degree (right now for an independent study course on digital generative art and next semester for experimental math) and am enjoying it immensely!
Posted by Tom De Smedt on Sep 26, 2006
Branton,
Keep me up-to-date with you progress, I'm now thinking of expanding the parser myself as well. SVG import might be a valuable NodeBox-library?
Nice to hear you like our software!
Posted by Tom De Smedt on Sep 26, 2006
There is now an SVG library online that handles curves, ellipses, lines, rectangles created in Illustrator. It even retrieves some information on fill and stroke colors and transparency.
http://nodebox.net/code/index.php/SVG
Posted by Branton Davis on Oct 2, 2006
I love you :)
Posted by Tom De Smedt on Sep 22, 2006
You can use the image() command, though it doesn't say so in the description of that command. I'll update the reference as soon as possible.
Illustrator documents retain their own colors (you can't change the colors with the fill() command for example) but you can scale, rotate and layer them how you like.
Here's an example.