-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I? #4
Comments
Thanks, you're right that they're missing from the documentation. I'll put them on the todo to add :) Creating a new STL file from scratch is a bit tricky right now, mainly because this library was initially written for the purpose of reading and modifying existing STL files. I'll modify that in a future version, for now there's only a hack available. Here's the current way to create a new from stl.mesh import Mesh
from stl.stl import StlMesh
VERTICE_COUNT = 100
data = numpy.zeros(VERTICE_COUNT, dtype=Mesh.dtype)
mesh = Mesh(data, remove_empty_areas=False)
# And to convert that to an STL object (NOTE THAT THIS IS NOT RECOMMENDED):
stl_mesh = StlMesh.__new__(StlMesh)
Mesh.__init__(stl_mesh, mesh.data) Where This is a hack to work around the current limitations as it wasn't designed with this purpose in mind, I can easily modify this in a future version but I would need a bit of info about how you plan to use the library :) Extending or reducing the mesh currently uses a similar process, the library is designed to take an existing mesh and rotate/translate/scale/etc. that mesh. If you want to extend/reduce it a new object would have to be created since the numpy storage used in the background doesn't have the features to shrink/grow either. Can you tell me how you plan to use the library? I can probably add the features you need easily :) |
I'm looking to experiment with 3-D printing, and want to use this library to create STL files that will be sent to a service bureau to have printed. For my use case it's easy enough to pre-compute the number of vertices, so extending and reducing isn't that important. As to saving a file, perhaps consider moving the save methods to the Mesh base class, possibly with a wrapper in the StlMesh class. This will allow saving of meshes that are created new and those that are loaded from files. |
I've just created a new release which supports creating a new mesh and saving it to file by using a common base class. This should provide enough extensibility for the future while still keeping the code separate :) Please give it a try and see if it works for you |
So far this library looks really cool.
Perhaps I'm missing something really obvious but there are two actions I don't see in the documentation.
How do I create and save a new stl file?
How do I extend or reduce the mesh for an existing mesh object?
The text was updated successfully, but these errors were encountered: