Permalink
Browse files

Some fixes for hacklab laser cutter gcode.

  • Loading branch information...
1 parent 8c4d54b commit 2d0218f3807f4bf53365e4abccccddb08d27a590 @colah colah committed May 1, 2012
Showing with 9 additions and 2 deletions.
  1. +1 −0 Graphics/Implicit.hs
  2. +4 −1 Graphics/Implicit/Export/PolylineFormats.hs
  3. +4 −1 extopenscad.hs
@@ -31,6 +31,7 @@ module Graphics.Implicit(
writeSVG,
writeSTL,
writeOBJ,
+ writeGCodeHacklabLaser,
runOpenscad
) where
@@ -6,6 +6,8 @@ module Graphics.Implicit.Export.PolylineFormats where
import Graphics.Implicit.Definitions
+import Text.Printf (printf)
+
svg :: [Polyline] -> String
svg polylines = text
where
@@ -38,8 +40,9 @@ hacklabLaserGCode polylines = text
"M5 (disable laser)\n"
++"G00 X0.0 Y0.0 (move to 0)\n"
++"M2 (end)"
+ showF n = printf "%.4f" n
gcodeXY :: ℝ2 -> [Char]
- gcodeXY (x,y) = "X"++ show x ++" Y"++ show y
+ gcodeXY (x,y) = "X"++ showF x ++" Y"++ showF y
interpretPolyline (start:others) =
"G00 "++ gcodeXY start ++ "\n"
++ "M62 P0 (laser on)\n"
View
@@ -6,7 +6,7 @@
-- Let's be explicit about what we're getting from where :)
import System.Environment (getArgs)
import System.IO (openFile, IOMode (ReadMode), hGetContents, hClose)
-import Graphics.Implicit (runOpenscad, writeSVG, writeSTL, writeOBJ)
+import Graphics.Implicit (runOpenscad, writeSVG, writeSTL, writeOBJ, writeGCodeHacklabLaser)
import Graphics.Implicit.ExtOpenScad.Definitions (OpenscadObj (ONum))
import Data.Map as Map
@@ -65,6 +65,9 @@ executeAndExportSpecifiedTargetType content targetname formatname = case runOpen
("svg", (_, x:xs, _)) -> do
putStrLn $ "Rendering 2D object to " ++ targetname
writeSVG res targetname x
+ ("ngc", (_, x:xs, _)) -> do
+ putStrLn $ "Rendering 2D object to " ++ targetname
+ writeGCodeHacklabLaser res targetname x
("stl", (_, _, x:xs)) -> do
putStrLn $ "Rendering 3D object to " ++ targetname
writeSTL res targetname x

0 comments on commit 2d0218f

Please sign in to comment.