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?
-
1$\begingroup$ Could you include the code you used for exporting to STL? $\endgroup$– MarcoBApr 18, 2016 at 4:00
-
$\begingroup$ I have the same problem when you cannot simply replace the PlotRange by restricting the parameter domain. $\endgroup$– user39553Apr 19, 2016 at 5:54
-
$\begingroup$ 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 $\endgroup$– Yves KlettApr 19, 2016 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
-
$\begingroup$ Nice example +1 $\endgroup$– user9660Apr 19, 2016 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
-
$\begingroup$ " I think that will do it." - have you tried? $\endgroup$– Kuba ♦May 20, 2017 at 10:47