Preparing Blender Models for Export to 3d Laser

  • A curved object like this requires processing before it can be engraved.
    A curved object like this requires processing before it can be engraved. 
  • This is the object in edit mode. It is made of curves. Unsuitable for engraving.
    This is the object in edit mode. It is made of curves. Unsuitable for engraving. 
  • This is the object after running the script. Made up of little triangles. Perfect for engraving.
    This is the object after running the script. Made up of little triangles. Perfect for engraving. 

I've written a script to prepare Blender models for 3d engraving. The 3d engraving software requires models to be a mesh made of triangular polygons. A typical Blender model isn't.

Usually I create models with a mix of text, curved objects, and meshes made up of quadrangular polygons. To prepare them for export involves:-

  1. Converting all objects to MESHs
  2. Selecting each object in turn and
    • Selecting all vertices
    • Removing overlapping vertices (Doubles)
    • Converting quadrangular polygons to triangles

Or in keyboard shortcuts, A >> Alt C >> >> Enter and then for each object ⇆ Tab >> A >> W >> R >> Ctrl T >> ⇆ Tab.

If I did one model occasionally, this wouldn't be an issue. But it is lengthy and tedious when doing a series of models, repetitively. So I wrote a script that does it for me :)

bl_info = {
    "name": "Crystallise",
    "author": "John Flower",
    "version": (0,1),
    "blender": (2, 5, 8),
    "api": 35853,
    "location": "View3D > Add",
    "description": "Prepares a model for crystal export",
    "warning": "",
    "wiki_url": "",
    "tracker_url": "",
    "category": "Mesh"}

import bpy

class OpCrystallise(bpy.types.Operator):
    bl_idname = "screen.crystallise"
    bl_label = "Crystallise"
 
    def execute(self, context):
        for ob in bpy.context.selected_objects:
            bpy.ops.object.mode_set(mode='OBJECT')
            bpy.ops.object.convert()
            bpy.ops.object.mode_set(mode='EDIT')
            bpy.ops.mesh.select_all()
            bpy.ops.mesh.quads_convert_to_tris()
            bpy.ops.mesh.remove_doubles()
            bpy.ops.object.mode_set(mode='OBJECT')
        self.report({'WARNING'}, "Crystallise")
        return {'FINISHED'}

# check poll() to avoid exception.
if bpy.ops.object.mode_set.poll():
    bpy.ops.object.mode_set(mode='EDIT')

# registering and menu integration
def register():
    bpy.utils.register_class(OpCrystallise)
 
# unregistering and removing menus
def unregister():
    bpy.utils.unregister_class(OpCrystallise)
 
if __name__ == "__main__":
    register()

Comments

Peter Egan

Please forgive my ignorance, but what is the purpose or function of this script? It seems fascinating, perhaps a bit too technologically advanced for my feeble mind to comprehend. Why would one want blender models for 3d engraving?For the record, I intend no offense whatsoever in asking this.

john
john's picture

Hi Peter,

I use this script almost daily to engrave inside crystals. I work for an engraving company in New Zealand. One of our machines is a 3d laser. It has software that requires models to be made up of triangles. This script turns all objects into triangles. Saving me a lot of time.

Below is an example of what i do:-

 

Regards,
John

leef lee

Hi,JohnI am interest in crystal engrving ,do you use any other software for crystal engraving besides blender?could you plz send me a copy of that ?thks.leef

john
john's picture

Hi Leef,

I use software made by Shanghai Lelee Laser Company to convert the model into a point cloud, then further proprietary software to drive the laser. Unfortunately it's not free. I have not looked into any open source software for this, so I don't know if it exists or not.

Blaq

Hi again John Can you answer on my previous question about file format exported from blender to convert model on point cloud? OBJ, DXF or maybe else?

john
john's picture

Hi Blaq,

I convert models into a point cloud using 3rd party software. This script is to prepare the model prior to exporting. It doesn't make a point cloud.

Bernd

Hi John,Same here. We are just on the brink of opening a crystal laser engraving store. I tried to import your script into blender 2.77 by various means. Once I added the script to the console and keep getting tons of syntax errors and secondly to just copy the .py script into the add on folder, where it shows up under user preferences but won't execute with error ´_RestrictContext´ object has no attribute ´scene`. I do have to say that I am a rookie with blender and it may be me. Any clues??

john
john's picture

This script works in Blender 2.59 but not all the newer versions.

Add new comment