Wednesday, 29 August 2012

Laser Slicer

I've written a little script, available on the scripts page, to slice up a mesh in Blender and export the slices as shapes in a SVG file that can be cut on a laser cutter. The mesh should be a manifold solid.
The script creates a panel within Blender's 3D tools menu where the thickness and dimensions of the cutting material can be specified. The slices will be roughly arranged to conform to the dimensions of the cutting material, although it does not do a perfect job of this, and exports a SVG file with the name 'blender file name'-laser.svg to the directory where the Blender file sits. The slices are all grouped together in the SVG file, but if you ungroup this top-level grouping then each slice can be rearrange on the page. Slices are taken in the z-direction  so make sure the mesh is orientated properly. By default 1 Blender unit is 1 metre. AS SVG files do not understand dimensions the scaling of the SVG file might change when loading it into your laser cutting software, so check for this. Below are the slices through the head of our holy mother, Suzanne.


Alas poor Suzanne, I knew her well.

29 comments:

  1. Hey Ryan.
    Nice work. 2 comments:
    1: We have a lasercutter at school and I am going to test this out for sure!
    2: It sounds like the innerworkings of this script could be modefied to maker a "section plane slice" addon for blender am I correct? I am not much into addon development in blender but that has been a sore miss by all architects of blender for many years... I would like to have a look at it if you think it is possible?
    Thanks man!

    ReplyDelete
    Replies
    1. Hi Ejnar.
      As I work in an architecture department I probably should have thought of that :). Yes I'll have a look see if I can get something together.
      Regards
      Ryan

      Delete
  2. Yeah, this would also go really well with 3d printing

    ReplyDelete
  3. I really want to try this script but I keep getting these errors in blender 2.62 when trying to slice the same object.

    File "C:\Users\testing3\AppData\Roaming\Blender Foundation\Blender\2.62\scripts\addons\LaserSlicer.py", line 210, in execute
    main(self, slicer_settings)
    File "C:\Users\testing3\AppData\Roaming\Blender Foundation\Blender\2.62\scripts\addons\LaserSlicer.py", line 147, in main
    pno=slice.data.polygons[0].normal
    AttributeError: 'Mesh' object has no attribute 'polygons'


    Any help would be greatly apprecciated.
    Thanks!
    Dave

    ReplyDelete
    Replies
    1. Hi Dave.
      I think the problem is that you are using a pre 2.63 version of blender. 'faces' became 'polygons' in 2.63. You can either get a newer copy of Blender or try changing every 'polygons' word to 'faces' in the script.
      Regards
      Ryan

      Delete
    2. Hey Ryan -
      It is an amazing script! I upgraded to the latest version of Blender and it works now! thank you very much! I did notice however a few of the slices near the top did overlap ever so slightly.....I'm assuming this is why you mentioned ungrouping and possibly re-arraigning them.
      Dave

      Delete
  4. Yes some rearrangement may be required. I haven't yet managed to figure why there is a slight overlap sometimes.
    Hope it proves useful.
    Ryan

    ReplyDelete
  5. This looks promising. But I can't get it to work. I have Blender 2.65 now and it doesn't throw any errors (except if I haven't saved the blender file). But as soon as I press the "Slice the object" button blender uses 100% of CPU time and hangs with no output on the command line. What exactly is supposed to happen when this button is pressed?

    ReplyDelete
    Replies
    1. I have tested both version 0.4 and 0.5 on 2.65 and it works fine. So maybe you are using version 0.5 and the mesh you have selected is not manifold because 0.5 does not accept non-manifold meshes? Or if the mesh is very large it can take a long time. Blender dimensions are metres for the script so if you have a mesh 2 units (2m) high and the default laser slice thickness is 2mm you are cutting a 1000 slices which will take a long time especially with v0.5. If the mesh is that big make it smaller or try using v0.4 which is quicker and will accept non-manifold meshes. You should see your selected mesh sliced into slices and an svg file should appear in the directory where you saved the Blender file with the layers printed out.

      Delete
    2. Thank you very much for your response. It just takes a lot longer than I thought it would and with the default settings it would probably have taken forever.

      Now I have one more problem. The mesh has an open end, which appears to be a problem for the script (all sorts of very strange shapes come out). At least it worked fine with other meshs. It's the first time I'm using blender. So I probably just have to figure out how to fix the mesh first.

      Delete
    3. The older version, available on the scripts page, could handle non-manifold meshes. The new one won't like it.

      Delete
  6. Oh cool, is there any solution how to separe every layer in to own file?

    ReplyDelete
    Replies
    1. That wouldn't be too difficult to do. I'll see if I can make some time this week to have a go.

      Delete
    2. oh, it would be nice, It would help me alot.

      Delete
  7. The laserslicer v0.7 script now has a 'separate files' option which will write out one svg file per slice.
    Enjoy.

    ReplyDelete
    Replies
    1. oh, one more thing, every slice is now snaped to left top cornder, can you please disable it, to be in real position?

      Delete
  8. HELLO!! the script don't working in blender 2.77a. the menu isn't created.

    ReplyDelete
  9. I just tested it on 2.77a and it worked OK for me. The menu should be under the misc tab of the 3D view tools bar.

    ReplyDelete
  10. Your script seems great and I am really excited to be able using it but for now, I am unable to make it work: no error but the menu is not created under the 3D view toolbar. I am using blender 2.78.a.
    Thanks!

    ReplyDelete
  11. I just checked it on 2.78a. Looked fine. The menu appears in the 'Misc' tab of the Viewport tools bar.

    ReplyDelete
    Replies
    1. I don't know what I am doing incorrectly but I cannot make it work, I have no "Misc" tab at all under the "3D Viewport" / "Tools" section. I only have "Transform", "Edit" and "History" entries...
      What can I do in order to try to understand what's going on?
      I am quite new at using blender, sorry if I am asking stupid things.

      Delete
  12. You should have little vertical arranged tabs on the left of the tools panel in the viewport. 'Misc' should be one of them if the laser slicer addon has been activated.

    ReplyDelete
  13. Excellent Script. Thank you Ryan.
    A question above concerned the placement of the slice in the file. Is it possible to center it?
    I have done similar things in the past cobbling together several programs, cutting the slices with a vinyl cutter (adhesive backed paper) and stacking them with good results. Now it is all in the one program I prefer to use.
    Again...thanks...nice work.

    ReplyDelete
  14. Thanks for your comment 3Dstudio.
    It's probably about time I updated this script. I will have a look and see if I can add this as an option.

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. Wow. I didn't expect such a quick response.
    I find the slicing process incredibly valuable and helpful. If you would like to seevhow I have used it, let me know how I can reach you. I am Savstudio(at)aol(dot)com.
    Steve

    ReplyDelete
  17. Hello Ryan and thanks for your script! I'm having the same issue as some others in this thread: I've installed and activated your addon, but there is no "misc" tab in my tool bar. I'm working on a Mac - could that be the problem? I'd love to get this resolved so I can use your slicer. Thanks so much for your help. Kelly

    ReplyDelete
  18. Hi.
    The tab is now called 'Laser' in the latest version of the script. If you still can't see it you'll have to tell me what version of Blender you're using and what version of the LaserSlicer.
    Ryan

    ReplyDelete