PDF to Blender MESH Conversion

This actually works pretty well and I want people to know that I didn’t spend a lot of time researching so I’m sure I’m about to hear that I did this all wrong from everyone, but here was my problem. I was getting plans from an architect in PDF format and I needed to use them for 3D model in blender. Here’s the process I used to get it in to blender.

Import PDF in to Inkscape.
Save File as Inkscape (inkscapes native format is SVG)
Go to blender and import SVG
You now have a million curves in blender.
{note: after being set straight ignore the lower section and do this
Select all of the curves and make sure you have an active curve object as the main selection.
Hit Ctrl - J
Hit Alt - c
}

Here is the script I wrote that was a waste of time because I didnt’ know the not section above:

Open the console window in blender so you can see status.
Select all of the curves with at least one of the curves being actively selected as well.
Run the script and press the button in the 3d view to convert all of the curves into a single mesh.
Watch the console, the script can take about fifteen minutes if you have thousands of curves which I did

And voila, a single mesh from a pdf. I am posting the script here for others (it’s really simple I wrote it in about fifteen minutes), but it did the job for me. The script simply converts thousands of curves into a single mesh. I am posting it here for posterity or in case it is useful in some way to someone else.

I am sure there is someone out there that is going to say… you idiot… press Ctrl-alt-F1-Shift-S or something completely non intuitive and I could have converted these curves with a single command, but blenders biggest weakness is figuring that magical combination out on your own, for me it’s easier just to write a python script.
{I was RIGHT!!! see below}

# ##### BEGIN GPL LICENSE BLOCK ######
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####


# <pep8 compliant>  that's Dr. Peppy of course


bl_info = {
    "name": "Curves to Single Object",
    "author": "Nick Keeline(nrk)",
    "version": (0, 0),
    "blender": (2, 7, 7),
    "location": "View3D > Tool Shelf > Curves to Single Object",
    "description": "Allows you to select millions of curves and convert them to meshes and combine them all in to a single object",
    "wiki_url": "NA"
                "NA",
    "tracker_url": "NA"
                   "NA",
    "category": "Object"}


import bpy
from bpy.props import BoolProperty, EnumProperty
from bpy.types import Operator, Panel


class VIEW3D_PT_tools_CamPaint(Panel):
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_label = "Curves to Single Object"
    bl_context = "objectmode"
    bl_options = {'DEFAULT_CLOSED'}


    def draw(self, context):
        active_obj = context.active_object
        layout = self.layout
        col = layout.column(align=True)
       
        col.operator("curve2obj.cur2obj", text="Curves to Object") 


class CameraPaint(Operator):
    """Setup a Camera to Paint on a Mesh"""
    bl_idname = "curve2obj.cur2obj"
    bl_label = "Curves to Single Object"
    bl_register = True
    bl_undo = True


    @classmethod
    def poll(cls, context):
        if not context.active_object:
            return False
        else:
            return ((context.active_object.type == 'CURVE'))


    def execute(self, context):  


        # Make variable that is the current .blend file main data blocks
        blend_data = context.blend_data
                      
        scene = bpy.context.scene


 
        objects = bpy.context.selected_objects
         
        curveobj = objects[0]
        i = 1
        numselectedobjs = len(bpy.context.selected_objects)
        for obj in objects:
            
            print ('Converting ' + str(i)  + ' of ' + str(numselectedobjs) + ' percent done:' + str(100*(float(i)/float(numselectedobjs))))
            # Deselect All
            bpy.ops.object.select_all(action='DESELECT')


            # Select the object
            obj.select = True
            scene.objects.active = obj
            
            bpy.ops.object.convert(target='MESH')
            i = i + 1
                


        for obj in objects:
            # Select the object
            obj.select = True
            scene.objects.active = obj
        
        scene.objects.active = objects[0]    
        bpy.ops.object.join()
        
        return {'FINISHED'}




def register():
    bpy.utils.register_module(__name__)






def unregister():
    bpy.utils.unregister_module(__name__)




if __name__ == "__main__":
    register()
 

You mean Ctrl+J, Alt+C.

LOL … Yeah THAT!!!

I tried ctrl J at first, but after trying it again I realized it didn’t work for me because I hit the A key and it didn’t work because there wasn’t an ACTIVE curve object. so I went the python route. I just tried it again with an active object and it worked. THis is the second time I wrote a python script to do something because I couldn’t figure out how to do it with a magical key combination… AAAAAAAAAAAAAArrrrgh!!! Key combinations are GREAT for stuff you do all the time, but finding them after being away a while and making them work is TERRRRIBLE!!!

I think I just chuckled for about five minutes about this… I KNEW someone was going to set me straight… Thanks JuhaW… how on earth do you figure this junk out when you forget?