# ParametricPlot3D does not export with the specified PlotRange?

I am trying to plot a function with ParametricPlot3D with a specified plot range to export as an stl file, however when exporting the graphic mathematica ignores the PlotRange and exports the whole function, is there a way to make this work or some sort of intersection command to work around this?

• Could you include the code you used for exporting to STL? – MarcoB Apr 18 '16 at 4:00
• I have the same problem when you cannot simply replace the PlotRange by restricting the parameter domain. – user39553 Apr 19 '16 at 5:54
• This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review – Yves Klett Apr 19 '16 at 6:57

## 3 Answers

As pointed out by Ivan Sterling, you cannot simply restrict the PlotRange, as this will not be respected when exporting to "STL". Take Louis's example,

ParametricPlot3D[{(2 + Cos[v]) Cos[u], (2 + Cos[v]) Sin[u],
Sin[v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi},
PlotRange -> {{0, π}, {0, π}, All}]
Export["test.stl", %] // Import


One method to make sure that you only get the plot you want is to restrict the parameter values, only plotting over the relevant values of u and v. But another option is to supply a RegionFunction

pp1 = ParametricPlot3D[{(2 + Cos[v]) Cos[u], (2 + Cos[v]) Sin[u],
Sin[v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi},
RegionFunction ->
Function[{x, y, z, u, v}, 0 <= x <= π && 0 <= y <= π]]
Export["test.stl", %] // Import


• Nice example +1 – user9660 Apr 19 '16 at 10:49

Works as intended on 10.0 for Mac OS X x86 (64-bit) (December 4, 2014), see also STL (.stl)

pp1 = ParametricPlot3D[{(2 + Cos[v]) Cos[u], (2 + Cos[v]) Sin[u],
Sin[v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi}]

Export["MathematicaParametricSurface.stl", pp1]


pp1 = ParametricPlot3D[{(2 + Cos[v]) Cos[u], (2 + Cos[v]) Sin[u],
Sin[v]}, {u, 0, 1 Pi}, {v, 0, 1 Pi}]

Export["MathematicaParametricSurface.stl", pp1]


Import["MathematicaParametricSurface.stl"]


Yes there is. Your problem is your looking at the "true points" not the adjusted points.

See Mathematica BoxRatios[{1,1,1}]. I think that will do it.

If it doesn't all I can say is see the following which will (can) do it. (you can adjust the rayshade.m if needed to suite the need of your renderer, by default rayshade` uses plain text scaling for BoxRatio - your renderer may or may not like that. it also contains ability that can be utilized (not automatically) to scale the actual points). That being said: you can just scale the points using Mathematica yourself BEFORE you export! It's easy just multiply all the vertex by a scaling vertex.

see:

https://sourceforge.net/projects/rayshade-math/

How to Render, raytrace, Export Graphics3D in Mathematica 11.0

• " I think that will do it." - have you tried? – Kuba May 20 '17 at 10:47