Message Boards Message Boards

0
|
31325 Views
|
19 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Converting data/graph into a 3D printable file (.stl or similar)

Posted 9 years ago

Hello.

I'm new to here. My name is Tomasz Klos and I'm a R&D Tech at IPG Photonics. I work with fiber-optic/diode lasers. Recently I came up with an idea to have a 3D printed model of a beam profile. I have a file (data) in the excel format that also shows a graph which is a illustration of the beam profile. Now I'm trying to convert that into a 3D model and further convert it to an .stl or similar file that a 3D printer will be able to print.

enter image description here

enter image description here

Attachments:
POSTED BY: Tomasz Klos
19 Replies

Hello, I have found several relevant posts here about converting 3D data to stl format for 3D printing. However, I have not seen how to increase the resolution that is used by Mathematica to make the stl file. When I use the standard commands I have seen so far, e.g. "Export["file.stl",obj]", the resolution is far to low for my needs. I should also note that I am using ParametricPlot3D to make my surface. I can easily increase the resolution of that plot using "Mesh" but it has no effect on the stl file created. How can I accomplish that task? Thanks!

POSTED BY: ELIZABETH WETZEL

OK. I got it. Whit small help from software engineer, I got the same result. Also tried a new one from scratch and it works. Thank you very much all for help.

POSTED BY: Tomasz Klos

Right now I have this on the new window in Math and the file its calling for IS on the desktop. Now how do I execute it?enter image description here

POSTED BY: Tomasz Klos

Ok yes this is exactly what I was looking for. That looks amazing. Now as I mentioned again, I'm very new to the Math program so please explain to me how do I execute the program.

POSTED BY: Tomasz Klos

OK. What about this?

p = ListPlot3D[0.1*Import["~/Desktop/test_2.txt", "TSV"][[2 ;;]], 
  PlotRange -> All, Mesh -> None, PlotStyle -> Red, Axes -> False, 
  Boxed -> False, Filling -> Axis, FillingStyle -> Red]

enter image description here

It exports nicely as stl:

Export["~/Desktop/test.stl", p]

Again, you will have to adapt the path.

Cheers,

M.

PS: The stl file is attached.

Attachments:
POSTED BY: Marco Thiel

It might also be that you are looking for this:

ListPlot3D[Import["~/Desktop/test_2.txt", "TSV"][[2 ;;]], PlotRange -> All]

enter image description here

You can also get rid of the grid:

ListPlot3D[Import["~/Desktop/test_2.txt", "TSV"][[2 ;;]], Mesh -> None, PlotStyle -> Thickness[250], InterpolationOrder -> 2,PlotRange -> All, Axes -> False, Boxed -> False]

enter image description here

Does this help at all?

Cheers,

Marco

POSTED BY: Marco Thiel

how do i even get the results like you do. I copied the above code to the new file in Math and made sure the source file is on desktop but then what? How do i get the 3d image like you did?

Thanks.

POSTED BY: Tomasz Klos

I am not sure what the problem is. If the data file is on the Desktop (I am on a Mac so you will need to adapt your path!), you just execute the command I posted and it should work.

You cannot use the "~/Desktop/..." part, because that does not work on Windows. You can use the Insert drop down menu and then File Path and then just pick the file. That should work on Windows, too.

Cheers,

M.

POSTED BY: Marco Thiel

the number of the column and the row is the XY location and then the value of the point itself will be the Z value.

Attachments:
POSTED BY: Tomasz Klos

ok my data contains 4096 points. 64 columns and 64 rows see attached file

Attachments:
POSTED BY: Tomasz Klos

This data set contains only one layer; the first one had more of them. I can plot this one, i.e. one layer, like so:

Import["~/Desktop/test_2.txt", "TSV"][[2 ;;]] // ListContourPlot![enter image description here][1]

When I constructed the 3D shape I only plotted one particular contour line. In 2D this works like so:

ListContourPlot[Import["~/Desktop/test_2.txt", "TSV"][[2 ;;]], Contours -> {250}]

enter image description here

The 3D case is similar; you only need to use ListContourPlot3D.

Cheers,

Marco

POSTED BY: Marco Thiel

Thanks Marco for these good words haha. For my 3D printing I use Cura. It's a free 3D software that let you modify your already created .stl file. Im comfortable with that. My struggle is the mathematica itself. I open a New file. I copied the code that was posted in one of the posts:

f[u, v] := {u, v, u^2 - v^2}; scale = 40; radius = 0.75; gridSteps = 10; curvesU = Table[scale*f[u, i], {i, -1, 1, 2/gridSteps}]; curvesV = Table[scale*f[j, v], {j, -1, 1, 2/gridSteps}]; tubesU = ParametricPlot3D[curvesU, {u, -1, 1}, PlotStyle -> Tube[radius], PlotRange -> All]; tubesV = ParametricPlot3D[curvesV, {v, -1, 1}, PlotStyle -> Tube[radius], PlotRange -> All]; corners = Graphics3D[ Table[Sphere[scale f[i, j], radius], {i, -1, 1, 2}, {j, -1, 1, 2}]]; output = Show[tubesU, tubesV, corners]

Export["MathematicaParametricSurface.stl", output]

And it shows there. ok. Now how do I input my data to create the object that I want???

POSTED BY: Tomasz Klos

Hi,

that would require me to try to figure out what your file actually contains, i.e. how many columns and rows etc. The basic idea could be like this. You first generate ContourLines in 3D. Something like this:

obj3d=ListContourPlot3D[Table[(Select[Import["~/Desktop/test.xls"][[2 ;;]], Length[#] == 64 &][[1 + k ;; 64 + k]]), {k, 0, 64*14, 64}], Contours -> {475}]

enter image description here

With the Contours-> {475} bit you can choose different contours. You can then make the walls thicker, just like in the links or with some external program like MeshLab. The obj3d can easily be exported like so:

Export["~/Desktop/test.stl", obj3d]

There are obviously many things that must be improved, but I hope it helps you to proceed. I would need more time, or more info to figure out how to better align the slices, but you should know what was measured.

Hope this helps.

Cheers,

Marco

POSTED BY: Marco Thiel

This is so complicated. Looks like I opened a Pandora's box to myself. How do I apply all these codes, programs and my data. How do I export it as a .stl at the end??? Please help.

POSTED BY: Tomasz Klos

Hi,

it's actually quite simple. In one of the links I posted above they show you how to export an stl-file:

Export["filename.stl", output]

It's as simple as that. Much of the remainder of the code they use is to make the two dimensional surfaces into three dimensional objects (obviously two dimensional objects cannot be 3D-printed).

One good piece of advice is to additionally use MeshLab to post-process the file and prepare it for printing. It is really quite straight forward.

Cheers,

Marco

POSTED BY: Marco Thiel

This:

http://community.wolfram.com/groups/-/m/t/176000

might be useful. I have successfully printed these/similar things. This might also be interesting:

http://community.wolfram.com/groups/-/m/t/139463

and this

http://community.wolfram.com/groups/-/m/t/401983

Cheers,

M.

POSTED BY: Marco Thiel

I'm not sure where to begin, I downloaded trial version of Mathematica. I'm so lost in this program. I'm able to open the data that creates the graph in the Mathematica but have no idea what to do with it next.

POSTED BY: Tomasz Klos

I'm sorry if I ask some stupid questions but this field I'm getting into to complete this task is new to me. ListPlot3D is that a free software???

POSTED BY: Tomasz Klos

Creating something that can print on a 3D printer is harder than creating a 3D graphic. I would recommend using RegionPlot3D for your purpose. But that's getting ahead of everything

I'm not sure how to interpret that data in your spreadsheet. The first step, I suppose would be to figure out how to plot your data with ListPlot3D (which I am guessing is the function you would use for your data based on the pictures you have)

POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract