Import .ai, .pdf

Is there any interest in an addon that imports Adobe Illustrator and PDF files (filled shapes) and makes quadrangulated faces out of them? Maybe the recently re-added svg importer makes this unnecessary?

EDIT:
Now with SVG import too.
For the latest version of the addon described in this thread, look here.

If someone wrote an addon that could do “smart quadrangulating” of an svg or ai file I’d be over the moon. The current addon doesn’t worry about what it will look like as a mesh – which is fine in many instances… but not all. Exporting a SVG from AI isn’t difficult, though, so we probably don’t need a separate addon for illustrator files.

I was hoping I could attach a zip file here with my addon (it is a directory with 6 files in it, about 3700 lines, so I can’t just paste code into a window here). But it only seems to take image attachments. What’s a good way to put code somewhere where it can be downloaded and tried out before being completely finished?

Just attach the BLEND file with the code in it. You can have multiple text files in a BLEND file.

Sorry, I’m pretty new to Blender. How do I make a BLEND file with code in it?

Open Blender. Near the top of your window you’ll see “Default” – click the icon just to the left of Default and you’ll have a drop-down of possible layouts. Choose “Scripting.” One of the windows that will appear in your Blender interface is a text window. Click the “New” button and paste your code in there. You can change the name of your text file from “Text” to whatever you want. Note that you don’t need to save the text file – it remains a part of your blend file once you’ve saved the blend somewhere. (You can save the text file externally, however, which is why the option is in the menus.)

or just rename your zip file to ‘file.zip.blend’ :slight_smile:

Thanks for the help all who replied. I do think the rename-to-.blend method is easiest for the users, so I’m using that. I hope that’s not frowned upon.

Here are instructions for trying this script, which works with 2.56.

It imports .ai and .pdf files. It only looks at filled shapes in those files (and not text).

It uses Delaunay triangulation, followed by a procedure that tries to remove as many edges as possible and leave “nice” quads.

If there is interest in this script, I can develop it further, by adding adaptive subdivision, extruding, and smart insetting.

To use it:

  • rename the attached file to impvec.zip and unzip the file in your addons directory (something like 2.56/scripts/addons in your blender installation); it will make a directory called io_vector with 8 python source files in it.
  • start blender, enable Import-Export: Vector import in User Preferences
  • restart blender, select menu item File > Import > Vector files (.ai, .pdf)
  • maybe change ‘number of subdivides’ in property panel: this is the number of times curves are subdivided in order to approximate with line segments
  • select an Adobe Illustrator or PDF file that contains some filled shapes and hit the ‘Import Vector’ button

I would love .ai import. A lot of the animation I do comes from illustrator and I would love to import the curves instead of rebuilding them from a background image reference. Haven’t had much luck with the .svg import but I’ll have to keep trying.

Did you (or anyone) try the plugin I attached above? I’d love some feedback.

I tried it, it would not even show up in user preferences.

Part of the problem with AI and PDF is that you are coding against a moving target. Which version of CS are you really targeting? Will you be there next year to update this script when Adobe improves the AI format and crashes your code?

Even Cinema 4D only supports AI8.

SVG already works, it is what I use as my bridge between Illustrator and Blender.

Thanks for trying. Wish I could figure out remotely why it doesn’t show up in user prefs. I know that when I tried a recent build as opposed to the most recent official 2.56a download, it stopped showing up in my prefs, and I found I needed to put an explicit call to register the addon into the init file; I thought I’d done that properly, because it worked for me (and I tried to make it backward compatible with the 2.56a download version too). Oh well.

I can see that with SVG support this seems like not a very needed plugin. That’s why I started the thread. Perhaps the thing that this script does is less steps and better quadrangulation, and soon, extruding with smart inset. I could easily add SVG support to it.

As far as the .ai version question goes: this supports both AI8 and earlier (which used an eps-based format) and AI9 and later (which uses a pdf-based format). Yeah, as each new CS version of AI comes out they add more and more metadata about complicated new features (live fills, complicated gradients, etc.), but I ignore all that because if all you want are the basic shapes, so far the well-documented standardized PDF format has worked across the whole series of CS versions.

But judging by the lack of response to this thread, I guess this plugin is not something that the Blender community is crying out for. Maybe I’ll move on to something else.

I wouldn’t give up so soon.
I am very interested in importing pdf or ai formats.
Having a print design and Apple background, I would really love to import my designs into Blender.
Until now I have always worked with svg addon.
I hope to get your plugin working so I can see the difference in mesh structure.

Keep up the spirit!

@howardt,
I’d still really love to be able to import AI / PDF files. The SVG importer works, but I still need to get the curve that it imports into a mesh. Just for my own file management purposes, being able to import AI would be really awesome!

I downloaded the script, I’ll try it out when I get a chance. Please don’t give up!

Tested the script with the latest Beta release 2.5.6
It works for me with PDF and ai files.
For text it would be great to have control over embossing/bevel somehow.

I think your addon has a different approche to importing vectors and can perfectly live besides the already excisting plugin.

Great work!

Thanks for some positive encouragement. I will continue working on this.
Beeckie68 - I have code in C++ to do nice beveling, I just need to translate it into python.

@howaqrdt,
I haven’t tested this script with 2.56a as I’m using the newest builds from graphicall.org (doesn’t work for me on these). I have to say I’m a little surprised more people haven’t shown interest in this script. The SVG format is great because it’s so universal, but I don’t store my vector files as SVG.

I’ve been an Illustrator user since version 7, having the ability to take out the step of exporting a SVG file to work with blender would be a great workflow boost. Over the years I’ve built a trove of vector stock art for myself and also have an enormous amount of client vector logos. Every file I have is stored as AI or PDF in my “library”, to keep my library files from going out of control I always delete/archive exported formats (png/svg/eps/etc.) when I’m finished with them. So being able to import AI natively without having to first export a SVG would remove a number steps in my workflow, working smarter not harder… isn’t that the end goal!

I really think this script would also help bridge a software gap for a lot of users. SVG is pretty well known format within the Open-Source crowd. But take the graphic design crowd, a lot of designers that I’ve worked with are so ingrained into all the Adobe products. When talking about Blender, the first question is “can it import Illustrator artwork” which the answer is “Yes, but…”. The moment you say SVG, they just look at you puzzled. Any of them that know any 3D apps usually mention Cinema 4D because it can import native AI files (only version 8 files I believe). When I opened Blender for the first time in 2006, first thing I did was try to figure out how to import Illustrator files (that coupled with trying to figure out the interface). Having native AI import built in would help bring a number of talented users into the Blender community, in my opinion of course. :wink:

I’d love to help you out in any way I could. Unfortunately I don’t know in what capacity I would be useful, I am one of “those designers types”. I can read a little bit of code and understand basics, but would be of no coding use for something like this (think of a bull in a room full of wine glasses). I can provide you any test AI files with any degree of complexity (typography or artwork), or test anything for you on the newer builds (I use recent 64bit builds from filiciss on graphicall).

For what it’s worth, using SVG import for my files. I always convert the curves to mesh, I use this amazing curves to uniform mesh script that’s being developed. Not sure if this would help to look at: https://github.com/decden/Blender-Curve-to-Uniform-Mesh

Also, at bit ago I ran into a very strange bug in Illustrator which is beside the point. Fixing it required using a function I never knew existed in Illustrator. Content Recovery Mode, which allows you to export a copy of an Illustrator file as an AI format, but can be opened in a text editor. You can then view all the code inside the AI file, make changes and then reopen the file in Illustrator. Maybe you might already know this, but here it is anyways if it’s useful in anyway on developing this script. http://kb2.adobe.com/cps/500/cpsid_50031.html

Thanks again, I definitely appreciate what you’re doing!

Thanks for the encouragement crazycourier. Could you tell me what graphicall.org version you tried where my plugin didn’t work? I downloaded a version from there just before I uploaded the script, and got it to work with that before uploading.
I think it has to do with understanding the proper way to register an addon, which seems to be a rapidly moving target.

35364 is the build number, here’s the build: http://www.graphicall.org/builds/builds/showbuild.php?action=show&id=1536

I’ve uploaded it to this directory, but nothing shows up in user prefs:
C:\Program Files\Blender Foundation\Blender\2.56\scripts\addons\io_vector

Comparing the init.py of other scripts in the import-export category. They all define a class before using “def menu_import(self, context):

This was the structure of one of them, please excuse my ignorance if you’ve already looked into this. As I said before I’m not a skilled programmer.

From the STL import, most every other one I checked defined a class like this.
class ImportSTL(bpy.types.Operator, ImportHelper):
‘’‘Load STL triangle mesh data’’’
bl_idname = “import_mesh.stl”
bl_label = “Import STL”

filename_ext = ".stl"

filter_glob = StringProperty(default="*.stl", options={'HIDDEN'})

files = CollectionProperty(name="File Path",
                      description="File path used for importing "
                                  "the STL file",
                      type=bpy.types.OperatorFileListElement)

directory = StringProperty()</i>

"

OK, I just tried build 35367 on a Mac and it fails for me. So at least I now have something to debug.
I was trying to follow the example of io_mesh_raw (where my defined class is in a separate file).
Yet somehow my class fails to get registered. I also tried bpy.utils.register_class, but no luck.

Does anyone know how to cause an addon to be reloaded from the Python console, so I can print debugging statements?