I have some 3D (x,y,z,value) data in python and I can visualize the isosurfaces in Mayavi. How can I export this isosurface into a file that I can read into Blender?
Here is some example code:
import numpy
from mayavi import mlab
x, y, z = numpy.ogrid[-5:5:64j, -5:5:64j, -5:5:64j]
values = x * x * 0.5 + y * y + z * z * 2.0
mlab.contour3d(values, contours=[.5])
mlab.show()
Using @timday's suggestion, I added the following code to save the isosurface in a wavefront (.obj) format:
mlab.savefig('surface.obj')
Then, I can open it in Blender with File>>Import>>Wavefront (.obj)
I had to scale down the image considerably (~100x) to make it visible in the Blender viewport.
The origin is set way off to the side of the actual object, so the object is easier to deal with if I use Object>>Transform>>Origin to Geometry
After adding some lighting and a plane, the object looks pretty good!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With