Crates.io | scad |
lib.rs | scad |
version | 1.2.2 |
source | src |
created_at | 2018-09-07 10:16:23.614389 |
updated_at | 2019-12-03 08:15:38.087049 |
description | A crate for generating OpenSCAD models using rust |
homepage | |
repository | https://github.com/thezoq2/Rust-Scad |
max_upload_size | |
id | 83424 |
size | 36,121,747 |
A library for creating openscad models using rust. I created this project partly because I wanted to learn more about rust and partly because openscad handles variables in a weird way. Variables in a single scope get assigned the last value they had in that scope at all points in that scope. This means that the following code
current_value = 0;
for( i = [0: 3])
{
current_value = current_value + i;
echo(current_value);
}
echo(current_value);
would print
0
1
2
3
0
instead of
0
1
3
5
5
as you would expect in most programming languages.
My library works around this issue by using rust to do all logic and generate simple scad code which accomplishes the same thing as more complex scad code would.
Using rust rather than the scad language also comes with other advantages such as being able to store scad objects in variables, static types and being able to use cargo for adding libraries with common objects.
Add the crate to your cargo.toml
[dependencies]
scad = "1.2"
And import the crate.
#[macro_use]
extern crate scad;
use scad::*;
Then read the documentation for a quick introduction to the library
The documentation can be found at docs.rs/scad
Since including dependencies in rust projects using cargo is so simple, I have a repository with some standard objects like nuts, screws and some RC things like servos in a separate repo which you can also include using cargo. For now it's undocumented but I will get around to that eventually.