Você está no 3DFinder
Buscamos em Thingiverse, MakerWorld e Printables ao mesmo tempo para te dar o melhor de cada uma.
Descrição
This is a simplistic library that allows you to generate valid constructive solid geometry (CSG) hierarchies in Haskell and translate them to OpenSCAD syntax.
Currently, the library allows you to export any generated hierarchy using the show function. A nice objective would be to interface directly with OpenSCAD/CGAL methods to export directly to STL.
Get the latest version from github: https://github.com/relet/scad.hs
Instruções
The library offers access to all documented OpenScad functions and discerns between 2D and 3D objects. Its objective is to leverage functional methods like maps and folds, but also to allow quick access to common operations without syntactic bulk. I just don't like to write difference() {} every time a dash would do the job.
Some examples: note that thingiverse eats up backslashes from where they are needed in lambda notation.
generator functions using common parameters:
- cube [1,2,3]
- square [1,2]
- sphere 10
- cylinder 10 6
- cone 0 10 6
- uCube -- a unit cube of size 1
- torus 15 5 8 8 -- a torus of radius 15+-5 with 8 steps of interpolation
optional parameters in template form:
- uCube {center=True}
- (sphere 10) {fn=6}
CSG operations:
- uCube /- uSphere -- infix notation
- uCube /+ uSphere
- uCube /. uSphere -- infix group {...} operation
- diff uCube uSphere -- prefix notation
- uCube /* 10 -- infix uniform scale operation
- uSphere // (10,3,2) -- infix scale operation
- uCube /> (4,6,6) -- infix translate operation
- scale (10,3,2) sphere
- inter cube sphere
2D/3D operations
- dxf 10 "myfile.dxf" -- dxf extrusion
- stl "myfile.stl" -- stl import
- extrude 10 uCircle -- just another cylinder
- project True uSphere -- just another circle
Parametric curves and planes:
- plane (\x-> \y-> [xpi,sin (y2pi) * sin(xpi), cos (y2pi) * sin(x*pi)]) 8 8 -- a lemon
- extrude 10 $ line (\x -> [sin (2xpi) * 10, cos(2xpi) * 10]) 10 -- a cylinder
- bezier [[0,0],[0,1],[1,0]] 10 -- arbitrary dimension/arbitrary order bezier curves
- bezierPlane [[[0,0,0],[0,0,1]],[[1,0,0],[1,1,1]]] 10 10 -- arbitrary d/o bezier planes
- bicubic [[0,0],[0,1],[1,0],[1,0],[1,-1],[2,-1],[2,0]] 6 -- arbitrary dimension bicubic bezier curve sequences (requires 3*n+1 points)
(Some) hierarchies can be rendered directly, also to STL: namely, all hierarchies consisting only of polyhedral primitives the library can generate. Note that this is heavily experimental.
- writeFile "cube.stl" $ toStl (Polyhedron Csg.cube)
- render $ myTorus /+ myPoly ...(more primitives might be added when I am back from holidays)...
EXAMPLE
import Scad main = print $ foldl1 (/+) $ map (\x -> trans (0,0,x) $ sphere (x/10)) [0,10..90]generates
union () {
translate ([0.0, 0.0, 0.0])
sphere(r=0.0);
translate ([0.0, 0.0, 10.0])
sphere(r=1.0);
translate ([0.0, 0.0, 20.0])
sphere(r=2.0);
translate ([0.0, 0.0, 30.0])
sphere(r=3.0);
translate ([0.0, 0.0, 40.0])
sphere(r=4.0);
translate ([0.0, 0.0, 50.0])
sphere(r=5.0);
translate ([0.0, 0.0, 60.0])
sphere(r=6.0);
translate ([0.0, 0.0, 70.0])
sphere(r=7.0);
translate ([0.0, 0.0, 80.0])
sphere(r=8.0);
translate ([0.0, 0.0, 90.0])
sphere(r=9.0);
translate ([0.0, 0.0, 100.0])
sphere(r=10.0);
}