-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Export to STL #154
Comments
From a quick hunt around crates.io, there seem to be two popular crates for working with STL files - I'm a little confused/concerned by the license of However, I've knocked together a branch with a first pass at an implementation and I was pleasantly surprised to find that macOS natively supports STL files in Preview - I'd still like to investigate exporting to an IndexedMesh as I think it might be a simpler approach (I've done no research to back this up). The files in the preview above were generated by running the below test script - #!/bin/sh
cargo run -- --model cuboid --export cuboid.stl
cargo run -- --model cuboid --export cuboid.3mf
cargo run -- --model cuboid --export cuboid.unknown
cargo run -- --model cuboid --export cuboid
cargo run -- --model group --export group.stl
cargo run -- --model group --export group.3mf
cargo run -- --model group --export group.unknown
cargo run -- --model group --export group
cargo run -- --model spacer --export spacer.stl
cargo run -- --model spacer --export spacer.3mf
cargo run -- --model spacer --export spacer.unknown
cargo run -- --model spacer --export spacer
cargo run -- --model star --export star.stl
cargo run -- --model star --export star.3mf
cargo run -- --model star --export star.unknown
cargo run -- --model star --export star
Which produces the following output -
Attached are the STL files. |
Thanks for looking into this, @chrisprice!
That's an unfortunate situation. The license would indeed be an issue. Fornjot is licensed under 0BSD, basically the most permissive license there is, and that's deliberate. Using a GPL-licensed library would completely change the requirements we put on people that want to use Fornjot libraries, or distribute anything from Fornjot. I just did a quick search and fount If, for some reasons, it doesn't, I suspect that rolling our own STL export would be practical as well. I haven't looked into STL in detail, but from what I know, it's a simple format. And for writing, we wouldn't even need to support all of it, just the subset we need. 3MF wasn't much of a problem, after all. |
I skipped over I've created a PR covering the |
Fornjot already supports exporting to 3MF. Since STL is also based on triangle meshes, adding support should be fairly straight-forward and not require many changes to existing Fornjot code.
The export code currently lives in
main.rs
. It can be extended to check the file ending of the export path, and choose the file format accordingly. I think this would also be a good opportunity to clean upmain.rs
a bit, and move that export code to a separate module.There might already be libraries for writing STL files that we can use. I haven't looked into that.
Labeling as https://github.com/hannobraun/Fornjot/labels/good%20first%20issue, as this doesn't require much knowledge of Fornjot, and might be a good introduction to it.
The text was updated successfully, but these errors were encountered: