Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export R object for 3D printing

Tags:

r

export

3d

If I have a data set in R, what would be a good way to export it so I could get it to a service like Shapeways for 3D printing?

I don't have any "real" CAD software, but I've used Google Sketchup before.

In my case the object can be described by two surface plots, something like this:

x <- y <- seq(0,1,by=0.01)
persp(x, y, outer(x, y, function(x,y) (x+y)^2))
persp(x, y, outer(x, y, function(x,y) rep(0,length(x))), zlim=c(-1,1))

...which I would like to appear together as one object to be printed. Any ideas?

like image 294
Ken Williams Avatar asked Dec 13 '13 03:12

Ken Williams


2 Answers

Shapeways says it can take output from MeshLab: http://sourceforge.net/projects/meshlab/files/meshlab

MeshLab, an open-source, free-as-in-beer project, is able to import this file using its .asc format option:

dat <- data.frame(x=x,   # will be recycled 101 times
                  y=rep(y, each=101),
                  z=as.vector(outer(x, y, function(x,y) (x+y)^2)))

write.table(dat, file="out.asc", row.names=FALSE, col.names=FALSE)

I probably should have done an sos-search;

library(sos)
findFn("3d printing")

.... did bring up the r2stl package whose sole function has the same name. It also found other convex hull functions that might be useful to others that want to build other 3D shapes from data.

like image 134
IRTFM Avatar answered Nov 12 '22 22:11

IRTFM


DWin has already made one suggestion for the mesh. If you need to export the resulting object from Meshlab and manipulate it in an extraordinarily intuitive 3D application that doesn't cost the earth then you should try MoI 3D.

I mention this because MoI has a very competent mesh engine and many of MoI's users seem to be involved in 3D printing (see for example this thread).

The developer Michael Gibson often responds to forum questions in, literally, minutes and other users in the forum are very supportive. There is a full 30-day trial version that allows you to experiment at no cost. MoI can also be scripted using JavaScript.

By its nature 3D printing is irrevocably real so it pays to be sure before you commit!

like image 43
SlowLearner Avatar answered Nov 12 '22 21:11

SlowLearner