from stl import mesh
from mpl_toolkits import mplot3d
from matplotlib import pyplot
# Create a new plot
figure = pyplot.figure()
axes = mplot3d.Axes3D(figure)
# Load the STL files and add the vectors to the plot
your_mesh = mesh.Mesh.from_file("/home/niroz/stl files/bottle/binary.stl")
axes.add_collection3d(mplot3d.art3d.Poly3DCollection(your_mesh.vectors))
# Auto scale to the mesh size
scale = your_mesh.points.flatten(-1)
axes.auto_scale_xyz(scale, scale, scale)
# Show the plot to the screen
pyplot.show()
Your code is assuming an older version of numpy
.
Newer versions of numpy
(mine is 1.14.0) you can check the docstring in IPython by typing
np.ndarray.flatten?
and what I'm getting is:
Docstring:
a.flatten(order='C')
Return a copy of the array collapsed into one dimension.
Parameters
----------
order : {'C', 'F', 'A', 'K'}, optional
'C' means to flatten in row-major (C-style) order.
'F' means to flatten in column-major (Fortran-
style) order. 'A' means to flatten in column-major
order if `a` is Fortran *contiguous* in memory,
row-major order otherwise. 'K' means to flatten
`a` in the order the elements occur in memory.
The default is 'C'.
The equivalent of passing -1
is the 'F'
option, i.e. the following snippet:
import numpy as np
foo = np.array([[1,2,3], [3,4,5]])
print (foo.flatten(-1) == foo.flatten('F')).all()
produces True
(and the DeprecationWarning
you're asking about).
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