Maperitive for laser cutting and 3D printing

From EduTech Wiki
Jump to: navigation, search

1 Introduction

Maperitive is a FREE desktop application for drawing maps based on OpenStreetMap and GPS data. You can define what gets on the map and how it is painted. You can also export these maps into bitmaps and SVG files and print them. (Maperitive home page, March 2017). The application is programmed in Net and needs Net 4.0 installed on Windows or the latest Mono under Linux.

We are exploring this since it can export SVG layers that could be useful for laser cutting and 3D printing

In this context, one needs to know the following:

  • By default, Maperitive will display a tiled bitmap map, called OSM Mapnik (the same that is used on the OSM main map site)
  • You will have to replace this map by vectorized maps. According to the FAQ,

“Maperitive rendering rules work on vector data, like OSM and GPX files. So you first need to load a vector file into Maperitive to see the actual rules in action. You can use File ”

2 Create contours for laser cutting

Using Maperitive to create laser cut model is an attractive option if you want to:

  • Cut along contour lines
  • Engrave extra information found in the OSM map

If you just plan to create a simple laser cut model of some terrain, we rather recommend slicing an STL model with Autodesk 123D Make. This software will create (almost) ready to print plates with numbered parts that one glue together.

Setting your zone of interest

  • Zoom out then in
  • Menu View -> Set home location
  • You now can export what you see. The result will be a tiled SVG file. Each tile is *.png file. Only the coordinates and the scale are SVG. This is not too useful for laser cutting or 3D printing.

2.1 Loading contour data

Read the Maperitive Tutorial: A Hiking Web Map In Ten Easy Steps. In summary the steps are the following:

  • Right click; Place Geometry bounds here
  • Adjust the rectangle
  • Get NASA SRTM DEM data: Menu Tools -> Generate Hillshading (Igor)
  • Turn off the Web Map (OSM Mapnik) in the Map source at bottom right.
  • Generate the relief contours: Menu Tools -> Generate Relief Contours.

Below are my exploration with the Salève, the "house mountain" of Geneva, its base 15 min from downtown.

2.2 Preparing for Laser cutting

You now can export to SVG and laser cut the contour lines. This is very tedious work. Consider using a tool that can automatically slice a 3D model and start from that.

  • Untick the image in the Map Sources (unless you want to use it for engraving)
  • Zoom in or out. Details of output will match zoom level !
  • Menu Tools -> Export to SVG
  • Open in a SVG editor like Inkscape
    • Get rid of layers you do not want
    • Lock all layers except the contour layer
    • Get rid of contours along the edges (optional)
    • Repair open lines. Typically you could edit the path in the following way: (1) Select the path, (2) Add a node in one of the 4 corners. (3) Link this node to the dangling ends. You also must close the lines that include an altitude number. Displace the number itself inside an area so that it can be engraved.
    • Arrange each contour line in a different spot (if the model is complex, consider adding a number, else find an otherwise logical arrangement
    • Make the lines "hairline" and select a color you like
    • Send to laser cutter.

Of course this only works with small areas !

Variant that adds roads

  • Download the OSM Data (in particular roads): Map->Download OSM Data (Overpass API)
  • You could export again in SVG, but the cleanup work required will be quite impressive, unless you really do a very small area. (not yet tested)

Saving an OSM map

Consider saving an OSM map locally. Do to so, use the export-osm command

export-osm file=output/saleve.osm

3 Creating contour creation scripts

Instead of using the menu, you could write a script. Firstly, learn how to modify the parameters. In particular, read Export-SVG Command

  • In the Assistant Window search for the command, e.g. export-svg
  • Double click on it. You will see export-svg in the Command prompt (bottom of main window)
  • Select various command parameters and play

You then can combine these into a script that you can load and run in the file menu. The following example will select an area south and east of Geneva, i.e. the Salève mountain and then export the contours to SVG

File saleve.mscript:

// This script will produce a 100m contour map of the Salève,
// the little house mountain south of Geneva (hiking, climbing, paragliding)
// Made by Daniel K. Schneider, TECFA, University of Geneva, March 2017

// loads the default map (this is done automatically already)
// add-web-map

// test
define font-size:8:8;12:12

// identifies the area of interest (lower left and upper right corner)
set-geo-bounds 6.075,46.035,6.24,46.183

// identifies what will be exported. Same coordinates as above.
set-print-bounds-geo 6.075,46.035,6.24,46.183

// Center somewhat the map so you can see
move-pos x=6.15 y=46.1

// Not necessary, but allows to see better.
generate-relief-igor color=gray

// generate contours (display will adjust to zoom level, see next)
generate-contours

// For laser cutting, make sure not to have too many contours
zoom-map-scale 150000

// Optional. Kill the bitmaps. In principle it should be the first map source in the list
remove-source index=1

// Export using a scale. Do not set a zoom here, unless you want to override the zoom map scale.
export-svg file="output/saleve/saleve.svg" compatibility=Inkscape scale=3 copy-images=true

// Optional. Load the bitmap we again.
add-web-map

4 Creating 3D models

Warning: Using Maperitive may not be the fastest way to create a terrain model. Since Maperitive uses standard STRM DEM data, there are easier ways to get a model with the same type of data, e.g. read 3D printing of digital elevation models‎‎

4.1 Export a *.dae file

Mapertive allows exporing a 3D model in Collada format, the format used by Google Earth for its buildings

An example would be:

  export-3d output-dir="output/saleve3D" ele-ratio=2 map-scale=50000

Setting a lower map-scale than 1:100'000 doesn't seem to have any effect, i.e. the original DEM data is not too precise.

However, you could lower the resolution. The simplest solution I found was the tin-error parameter

 tin-error=10

Script that defines an area and loads OSM data:

// This script will produce a 100m contour map of the Salève,
// the little house mountain south of Geneva (hiking, climbing, paragliding)
// Made by Daniel K. Schneider, TECFA, University of Geneva, March 2017

// loads the default map (this is done automatically already)
// add-web-map

// get OSM data (uncomment the first time)
// download-osm-overpass
// export-osm file="output/saleve.osm"

// Load an OSM file
load-source file="output/saleve.osm"

// identifies the area of interest (lower left and upper right corner)
set-geo-bounds 6.075,46.035,6.24,46.183

// identifies what will be exported. Same coordinates as above.
set-print-bounds-geo 6.075,46.035,6.24,46.183

// Center somewhat the map so you can see
move-pos x=6.15 y=46.1

// Export with 200% extra elevation and the max meshpoints
export-3d output-dir="output/saleve3D" ele-ratio=2 map-scale=50000 mesh-points=100000

4.2 Import to sketchup and export

If opened in Meshlab, the file looks like a bird's nest. There is probably a filter that could fix this, but I don't know which one. Anyhow, opened in sketchup, the model looks OK, but is not printable as is since it only represents a hilly surface.

  • Use the 3Dprinting millimeters template (before doing anything) and not a m(eter) Model !
  • Get rid of the Makerbot propaganda if you can...
  • File->Import
  • Options: Tick Merge Coplanar Faces, You can untick the validation if it takes too much time
  • Select the *.dae file.
  • Click in the scene (otherwise the object never will be there ...) then hit ESC
  • Menu Camera: Parallel projection
Importing a *.dae file to sketchup

This model is not printable yet. It is not solid and not a box. You now can add a box in Sketchup or else extrude the 2D terrain to make it volume. Another solution is to use an other tool. Since I find Sketchup difficult to use for such things, I strongly recommend buying the $20CAN AccuTrans Tool.

In either case, export the model again

  • File->Export 3D model

4.3 Create an STL with a bottom using AccuTrans

  • Get Accutrans if you do not already own it.
  • Open the *.dae file
  • Select Tools -> Extrude Pseudo 2D Surface
    • Tick "Flat Bottom"
    • Add thickness that represents maybe 5-10% of the total Z height, e.g. 50000 for the Swiss top map.
    • Click on Extrude.

(Optional) You also could use Accutrans to scale the model to the right dimensions and positions and rotate

  • Tools_1 -> Adjust object parameters
    • Click on Calculate scale. Select the larger x or y value, then enter a desired result, e.g. 200 because your printer will want millimeters and your print bed is not much bigger than that. You always can fine tune in the STL editor.
    • Hit the scale button
    • Rotate 90deg around the X axis
    • Tick Set Min at 0.0.0
    • Click OK at the bottom.
3d *.dae terrain model with a bottom

Export to STL

  • Save as, select STL

4.4 STL manipulation

We found that models are error free and could be printed as is. However, you might:

  • reduce triangles
  • Scale (Accutrans can do this also)
  • Rotate (Accutrans can do this also)

Anyhow, import to Netfabb (or another STL tool)

  • Repair (just to make sure)
  • You likely will have to scale and position the model. Collada files are always way too huge and mispositioned. E.g. I once had to divide by 2000 (scale = 0.0005)
  • Move to origin (the model will sit in some outerspace area !)
  • Rotate if needed
  • Scale
  • Move to origin again.

5 Installation under Ubuntu

Prerequisites

  • Mono (a .Net implementation)

There are many mono ubuntu packages and I frankly do not know which are needed, I just got the complete set (but it's not that huge)

sudo apt-get install mono-complete

Download as zip file from Maperitive, Dowload the latest version

unzip ...
cd Maperitive
chmod a+x Mapertive.sh
./Maperitive.sh &

You also could modify this script to work from any place, i.e. add add this directory to your path

edit ~/.bashrc
e.g. export PATH=/home/_you_/Maperitive:$PATH

Then fix the Maperitive.sh script itself. The following will only run from the installation directory:

#!/bin/sh
 mono --desktop Maperitive.exe "$@"

E.g.

 !/bin/sh
 mono --desktop /home/schneider/Maperitive.exe "$@" &

Link to something that is easier to remember or dock to the Launcher.

 ln -s Maperitive.sh maperitive

6 Links