Sunday, June 29, 2014

Filleting or Chamfering Paths in Inkscape

In our maker lab there is are currently two 3D printers and a desktop CNC mill. I wanted to be able to make time lapse videos and also just have the ability to check progress on the machines. I was designing a case from scratch for a Raspberry Pi with a servo camera mount. In order to make this part I wanted to use our CNC mill. I could have cut these pieces on a laser cutter, but I'm having fun learning about CNC milling. There aren't any pockets on here, but with a mill you can do pocketing and potentially other 2.5d/3d surfacing that a laser cutter just can't do. I had just found some free scrap ply so I figured it would be fun to utilize it. I roughed out the profiles in inkscape using rectangles, and it just seemed too sharp to me. I decided to round over the corners on the side pieces to give it a nicer silhouette. Sure I could have probably used another tool to do this much more quickly and easily, but I'm challenging myself to stick to using only open source or freeware options in my toolchain when possible.

I couldn't find anywhere that would allow me to easily select corners to fillet or chamfer on my closed path. This was slightly discouraging at first but I thought there must be a way, as I poked around in the fill/stroke properties panel. The "Join" option looked like what I wanted, but it only changed the stroke, not the overall dimensions, which is not what I wanted. I googled for an answer and didn't find much on forums, but I did find this one youtube video:



This video was kind of hard to parse for me, so I wanted to document the steps myself here. In the future I can refer back to this post when I need this functionality. Essentially what we do is a hack, but it works. You use your original path to create a Round or Bevel join that is the diameter of the intended corner radius. Then break that stroke up into individual paths. You repeat this procedure on the newly created "inside and outside" paths. At the end of this you can delete all of the "guidelines" and you're left with just the path parts we wanted. Combine these into one path and we're done! Simple right?

  1. Select Path
    • We'll be destructively modifying this, so if you want to keep the original make a duplicate now.
  2. Open the Fill and Stroke Properties Panel (Ctrl + Shift + F)
  3. Under Stroke Style Set the stroke width to 2x the radius you want on your corners
  4. Under Join type select Round join or Bevel join
  5. From the Path Menu select Stroke to Path (Ctrl + Alt + C)
  6. From the left Toolbar select Edit paths by nodes (F2)
    • If "Show path outline" is not turned on, you may want to do this now. End of second toolbar from the top.
  7. From the Path Menu select Break Apart (Shift + Ctrl + K)
  8. Keeping both paths selected, Apply any color Stroke Paint
  9. Under Stroke Style again, set the width 2x the radius and click the Round or Bevel button again
  10. Again, From the Path Menu select Stroke to Path (Ctrl + Alt + C)
  11. Again, From the Path Menu select Break Apart (Shift + Ctrl + K)
  12. You only need the two innermost hulls now, select the others and remove them
    • For this example I've colored the path's stroke green, magenta, blue, and green. Delete the green parts
  13. When you're left with the 2 paths select them both
  14. From the Path Menu select Division (Ctrl + /)
  15. This will create one main path and pieces at each corner. The outside corners and inside corners are formed differently, so select the ones that are not the way you want and delete them.
    • I selected all of the outside corners and deleted the Miter join. I actually don't want the inside corners filleted, so I deleted that part to maintain the original Miter join
  16. If you have more than one part remaining select them all
    • From the Path Menu, select Combine (Ctrl + K)
  17. Select your one path and set your fill and stroke to what you want
    • Change your stroke size back to 1px or whatever you want it to be
  18. As you can see, I've knocked off the corners perfectly and am left with the path I desire. Black is the original duplicate I made, green is the newly created path with fillets. Original path is 8 nodes, new path is 108.
I hope this set of instructions is easy enough to get people going. If someone out there is an Inkscape guru, maybe this can be made into an extension/plugin type deal to automate the process?