Crates.io | solidrs |
lib.rs | solidrs |
version | 0.4.0 |
source | src |
created_at | 2024-02-19 01:01:17.866886 |
updated_at | 2024-03-14 08:40:56.88643 |
description | Rust library to generate openScad models. Inspired by SolidPython. |
homepage | https://github.com/MnlPhlp/solidrs |
repository | https://github.com/MnlPhlp/solidrs |
max_upload_size | |
id | 1144567 |
size | 41,340 |
Rust library to generate openScad models. Inspired by SolidPython.
Currently only very few commands are implemented but I plan on adding them as I need them.
use solidrs::*;
fn main() {
let a = cube(10, 20, 5).center();
let b = cylinder(10, 5).translate(0, 0, 2.5);
let c = a + b;
c.save_as_scad("test");
}
SolidRS is able to generate variables in the resulting openSCAD script. These variables can then be configured in the openSCAD Editor.
this rust file:
use solidrs::*;
fn main() {
var!(width, 10, "cube width");
var!(height, 20, "cube height");
let a = cube(width, width / 2, height).center();
// you can save calculated points
// they will still be displayed as the calculation when rendering
let cube_top = height / 2;
// if you use var to save it, the calculation will also be written to a variable in openScad
var!(cylinder_height, width / 2);
let b = cylinder(cylinder_height, 5).translate(0, 0, cube_top);
let c = a + b;
// variable values can be changed at any point
width.set(20);
c.save_as_scad("vars");
}
produces this scad file:
// cube width
width = 20;
// cube height
height = 20;
cylinder_height = width / 2;
union(){
cube([width,width / 2,height],center = true);
translate([0,0,height / 2]){
cylinder(cylinder_height, r = 5);
}
}