Connect with us

Gerber to G-Code, Help needed.

Discussion in 'CAD' started by chapmjw, Oct 21, 2006.

Scroll to continue with content
  1. chapmjw

    chapmjw Guest

    Hello folks,

    I've written software that converts Eagle PCB output to G-Code so you
    can use any 3 axis mill create a quick circuit board. Every thing works

    perfectly from eagle but i'll like to be able to import a gerber file,
    then convert to G-Code.


    I have no problem converting Gerber code and displaying it. The
    difficulty starts when you have rearange all intersecting element types

    and then gernerate offset toolpath geometry.


    Is there any one out there that has done this?
    Is there any one that would like to help with this project?


    thanks
    jim
     
  2. Guest


    A couple months ago I wrote a similar script in the TCL language. It
    can take an excellon file from Eagle, and convert it to a bunch of
    G-code circle cuts, offset for a known mill bit size, optionally with
    multiple plunges depths for thicker boards. As I recall, I used the
    excellon format, as it contained the drill sizes in the same file, but
    otherwise it's very similar to gerber.

    My script kind of relies on a larger suite of TCL scripts I've made for
    vertical milling, though. They create a kind of mid-level language for
    milling things. I can tell it I want circles and polygons cut out to a
    given depth, with a given material, using a given mill bit, and it
    works out the G-code for it, including feeds, speeds, multiple plunge
    depth cuts, and inset pocket clearing. It's not intelligent about
    merging pockets, though.

    The main trick in eagle, was telling it to not make vias smaller than
    1/32nd inch in size, which is the size of the mill bit I used.

    My script follows. You'll need to make a new mlcnc_g_circle proc to
    output the G-code for the individual circles, with moves in between.
    My scripts to do that are quite involved, and take into account all
    sorts of stuff like mill bit type and coating, stock material, cut
    depth, and such, which you don't really need for this, and which would
    take up a lot more space here. If I had more time, I would whip up a
    simplified mlcnc_g_circle proc.

    - Garth



    # filename is the name of the excellon file to convert.
    # z is the Z depth to cut to.
    proc mlcnc_g_excellon {filename z} {
    set f [open $filename "r"]
    set holesInfo {}
    set section "start"
    set conv 1.0
    set currdiam 0.0
    while {![eof $f]} {
    if {[catch {
    set line [gets $f]
    }]} {
    break
    }
    if {$line == "M71"} {
    set conv [expr {1.0/25.4}]
    } elseif {$line == "M72"} {
    set conv 1.0
    }
    if {[regexp {^ *T *([0-9][0-9]*) *C
    *([0-9][0-9]*\.[0-9][0-9]*).*$} $line dummy toolnum diam]} {
    set toolnum [string trimleft $toolnum "0"]
    set diam [expr {$diam+0.0}]
    set toolsInfo($toolnum) $diam
    } elseif {[regexp {^ *T *([0-9][0-9]*).*$} $line dummy
    toolnum]} {
    set toolnum [string trimleft $toolnum "0"]
    if {![info exists toolsInfo($toolnum)]} {
    error "Malformed excellon file. May
    require extra drill tool file. We don't handle that yet."
    }
    set currdiam $toolsInfo($toolnum)
    } elseif {[regexp {^ *X *([0-9][.0-9]*) *Y
    *([0-9][.0-9]*).*$} $line dummy x y]} {
    if {[string first "." $x] != -1} {
    set x [expr {$x*$conv}]
    set y [expr {$y*$conv}]
    } else {
    set x [expr {$x*$conv/10000.0}]
    set y [expr {$y*$conv/10000.0}]
    }
    lappend holesInfo $x $y $currdiam
    }
    }
    set out {}
    foreach {x y diam} $holesInfo {
    set rad [expr {$diam/2.0}]
    append out [mlcnc_g_circle $x $y $z $rad $rad]
    }
    return $out
    }
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-