How to measure laser cut length or time?

Posted on Tuesday, May 31st, 2016 in #liveupdates, site by Ian


To price laser cutting online we need to extract two pieces of info from uploaded design files. The area of a box surrounding the design, called the bounding box, is the amount of material needed. The length of all the cuts in the design can be used as a rough estimate of the cutting time consumed. Here’s where we’re at…

A dirty cheap laser cut service has been “coming very soon” for far too long. We planned to take SVG files and use a friend’s script to measure the bounding box and cut lengths. Unfortunately we never found a laser cut supplier willing to take low volume/high-mix orders and provide all the pricing info to give instant quotes.

Last week a comment at Hack a Day mentioned that dirty laser cutting is taking forever. Surprised by the interest, we asked around and found some willing suppliers. However, these suppliers only accept dxf, dwg, pdf, eps, and ps formats. SVG won’t do. Now we have a supplier but no way to give instant online quotes.


Converting to and from SVG is plagued with wrecked arcs and curves. Potential customer dissatisfaction factor is super high. Absolutely not reliable enough for a commercial service or even for pricing.

Extracting info from CAD programs

Inkscape loads all the above formats, but we were not able to extract total path length from the command line or the shell interface. is an online version of AutoCAD that might be able to provide the design stats and a nice rendering, but if the API is slow or busy are customers supposed to wait minutes for their quotes?

A couple CAD programs seemed promising, but eventually we couldn’t find anything that runs on Linux and can extract the stats we need via the command line.

Measuring scripts

The script that measures PCBs in our store and at DirtyPCBs combines a bit of gerber code knowledge with some math to crank out basic stats without ever loading a CAD program. A small script to extract path length and bounding box size from dxf is very doable after a quick thumb through the spec, however nothing seems to exist online.

The learning curve to implement the dxf format and the debug time to perfect it puts this in the labor of love category. It would be a blast if we really wanted to do it, but since it’s standing in the way of a dirt cheap service that will likely never turn a profit (laser cutting is cheap and common…) there’s no resources to dedicate to writing our own.

Create g-code and simulate the cut

G-code is a popular way to control CNC mills and 3D printers. A CAM processor (yes, like the one in Cadsoft Eagle) combines information about the machine, such as cut speed, with the path in the design file to create a series of cutting steps or instructions. G-code is accepted universally, much like gerber files.

Lots of existing scripts convert dxf/pdf/eps/ps files to g-code. Once the design is in g-code there are several programs that simulate the cut and estimate the cut time (or filament used, etc). This seems like the proper way to do it. As a bonus, it lays the framework to calculate cut time and difficulty for a future DirtyCNC and DirtyInjectionMolding service.

This is as far as we’ve gotten. A dozen Python scripts on github look promising, but nothing directly outputs the info we need without a bit of hacking. We’ll continue to knock together a solution in the next few days.

Please shout out in the comments if you have thoughts on any of these methods or experience with any tool chains that might work. Help us get laser cutting online and we’ll reward you with – what else – free laser cutting service!

Image source: Adam Dingley CC BY SA

This entry was posted on Tuesday, May 31st, 2016 at 12:30 pm and is filed under #liveupdates, site. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

5 Responses to “How to measure laser cut length or time?”

  1. Peter says:

    Hi Ian. I went through a lot of this already. In my open source laser cam/control software: LaserWeb and LaserWeb2 i hace working imports for svg and dxf. And i can get the cut time (including even feedrate, and acceration moves) as well as bounding box. I’d be happy to help dirty corp out with a viewer + esimate (we can add a materials library that predicts the cut speed with ease. Let me know if you’d like the help. I’ll help with pleasure! Checkout (note i am not displaying these values in the foreground but they are calculated in the background in gcode-parser.js. In LaserWeb v1 we do display both.

  2. langwadt says:

    convert to BW bmp and count the black pixels?

  3. Ponoko provides instant price quotes for SVG files created in Inkscape (among other formats). I don’t know if they’d share their methods with you, or at least give you some pointers, but it couldn’t hurt to ask. The CEO is Derek Elley and his email goes to anyone who cancels their Prime subscription, if you need a contact person.

Leave a Reply

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Recent Comments

  • Drone: I feel your Pain Max...
  • Drone: Ugh, now every other post on HaD for ages will be about the "Hackaday Prize" - and go on-and-on-and-on... :-(
  • Max: Hey, look - an article that isn't conveniently obfuscated into a video! Something I can actually, you know, _read_!
  • Andrew: Me!!
  • techdcs: I shall take Free PCB as gift for EASTER