mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-04-21 09:01:58 +02:00
Online demo of fix: https://ochafik.com/openscad2/#%7B%22params%22%3A%7B%22sourcePath%22%3A%22%2Fhome%2Fplayground.scad%22%2C%22source%22%3A%22include%20%3CBOSL2%2Fstd.scad%3E%5Cninclude%20%3CBOSL2%2Fgears.scad%3E%5Cninclude%20%3CBOSL2%2Fbeziers.scad%3E%5Cninclude%20%3CBOSL2%2Fscrews.scad%3E%5Cninclude%20%3CBOSL2%2Fcubetruss.scad%3E%5Cn%5Cn%24fa%3D1%3B%5Cn%24fs%3D1%3B%5Cn%5Cnxdistribute(50)%20%7B%5Cn%5Ctrecolor(%5C%22%23f77%5C%22)%5Cn%5Ctdiff(%5C%22hole%5C%22)%5Cn%5Ctcuboid(%5B45%2C45%2C10%5D%2C%20chamfer%3D10%2C%20edges%3D%5BRIGHT%2BBACK%2CRIGHT%2BFRONT%5D%2C%20anchor%3DFRONT)%20%7B%5Cn%5Ct%5Cttag(%5C%22hole%5C%22)cuboid(%5B30%2C30%2C11%5D%2C%20chamfer%3D5%2C%20edges%3D%5BRIGHT%2BBACK%2CRIGHT%2BFRONT%5D)%3B%5Cn%5Ct%5Ctattach(FRONT%2CBACK%2C%20overlap%3D5)%20%7B%5Cn%5Ct%5Ct%5Ctdiff(%5C%22hole2%5C%22)%5Cn%5Ct%5Ct%5Ctcuboid(%5B45%2C45%2C10%5D%2C%20rounding%3D15%2C%20edges%3D%5BRIGHT%2BBACK%2CRIGHT%2BFRONT%5D)%20%7B%5Cn%5Ct%5Ct%5Ct%5Cttag(%5C%22hole2%5C%22)cuboid(%5B30%2C30%2C11%5D%2C%20rounding%3D10%2C%20edges%3D%5BRIGHT%2BBACK%2CRIGHT%2BFRONT%5D)%3B%5Cn%5Ct%5Ct%5Ct%7D%5Cn%5Ct%5Ct%7D%5Cn%5Ct%7D%5Cn%5Cn%20%20%20%20recolor(%5C%22%237f7%5C%22)%5Cn%5Ctbevel_gear(pitch%3D8%2C%20teeth%3D20%2C%20face_width%3D12%2C%20shaft_diam%3D25%2C%20pitch_angle%3D45%2C%20slices%3D12%2C%20spiral_angle%3D30)%3B%5Cn%5Cn%5Ctx%20%3D%2018%3B%5Cn%5Cty%20%3D%2020%3B%5Cn%5Cts1%20%3D%2025%3B%5Cn%5Cts2%20%3D%2020%3B%5Cn%5Ctsbez%20%3D%20%5B%5Cn%5Ct%5Ct%20%20%20%20%20%20%20%20%20%20%20%20%5B-x%2C-y%5D%2C%20%5B-x%2C-y-s1%5D%2C%5Cn%5Ct%5Ct%5B%20x%2C-y-s1%5D%2C%20%5B%20x%2C-y%5D%2C%20%5B%20x%2C-y%2Bs2%5D%2C%5Cn%5Ct%5Ct%5B-x%2C%20y-s2%5D%2C%20%5B-x%2C%20y%5D%2C%20%5B-x%2C%20y%2Bs1%5D%2C%5Cn%5Ct%5Ct%5B%20x%2C%20y%2Bs1%5D%2C%20%5B%20x%2C%20y%5D%5Cn%5Ct%5D%3B%5Cn%5Ctrecolor(%5C%22%2399f%5C%22)%5Cn%5Ctpath_sweep(regular_ngon(n%3D3%2Cd%3D10%2Cspin%3D90)%2C%20bezpath_curve(sbez))%3B%5Cn%5Cn%5Ctrecolor(%5C%22%230bf%5C%22)%5Cn%5Cttranslate(%5B-15%2C-35%2C0%5D)%5Cn%5Ctcubetruss_corner(size%3D10%2C%20strut%3D1%2C%20h%3D1%2C%20bracing%3Dfalse%2C%20extents%3D%5B3%2C8%2C0%2C0%2C0%5D%2C%20clipthick%3D0)%3B%5Cn%5Cn%5Ctrecolor(%5C%22%23777%5C%22)%5Cn%5Ctxdistribute(24)%20%7B%5Cn%5Ct%5Ctscrew(%5C%22M12%2C70%5C%22%2C%20head%3D%5C%22hex%5C%22%2C%20anchor%3D%5C%22origin%5C%22%2C%20orient%3DBACK)%5Cn%5Ct%5Ct%5Ctattach(BOT%2CCENTER)%5Cn%5Ct%5Ct%5Ct%5Ctnut(%5C%22M12%5C%22%2C%20thickness%3D10%2C%20diameter%3D20)%3B%5Cn%5Ct%5Ctscrew(%5C%22M12%2C70%5C%22%2C%20head%3D%5C%22hex%5C%22%2C%20anchor%3D%5C%22origin%5C%22%2C%20orient%3DBACK)%5Cn%5Ct%5Ct%5Ctattach(BOT%2CCENTER)%5Cn%5Ct%5Ct%5Ct%5Ctnut(%5C%22M12%5C%22%2C%20thickness%3D10%2C%20diameter%3D20)%3B%5Cn%5Ct%7D%5Cn%7D%5Cn%22%2C%22features%22%3A%5B%22manifold%22%2C%22fast-csg%22%2C%22lazy-union%22%5D%7D%2C%22view%22%3A%7B%22layout%22%3A%7B%22mode%22%3A%22multi%22%2C%22focus%22%3Afalse%2C%22editor%22%3Atrue%2C%22viewer%22%3Atrue%2C%22customizer%22%3Afalse%7D%2C%22logs%22%3Atrue%7D%7D
BOSL2
The Belfry OpenScad Library, v2
A library for OpenSCAD, filled with useful tools, shapes, masks, math and manipulators, designed to make OpenSCAD easier to use.
Requires OpenSCAD 2021.01 or later.
- NOTE: BOSL2 IS BETA CODE. THE CODE IS STILL BEING REORGANIZED.
- NOTE2: CODE WRITTEN FOR BOSLv1 PROBABLY WON'T WORK WITH BOSL2!
Installation
- Download the .zip or .tar.gz release file for this library.
- Unpack it. Make sure that you unpack the whole file structure. Some zipfile unpackers call this option "Use folder names". It should create either a
BOSL-v2.0
orBOSL2-master
directory with the library files within it. You should see "examples", "scripts", "tests", and other subdirectories. - Rename the unpacked main directory to
BOSL2
. - Move the
BOSL2
directory into the apropriate OpenSCAD library directory for your platform:- Windows:
My Documents\OpenSCAD\libraries\
- Linux:
$HOME/.local/share/OpenSCAD/libraries/
- Mac OS X:
$HOME/Documents/OpenSCAD/libraries/
- Windows:
- Restart OpenSCAD.
Examples
A lot of the features of this library are to allow shorter, easier-to-read, intent-based coding. For example:
BOSL2/transforms.scad Examples |
Raw OpenSCAD Equivalent |
---|---|
up(5) |
translate([0,0,5]) |
xrot(30,cp=[0,10,20]) |
translate([0,10,20]) rotate([30,0,0]) translate([0,-10,-20]) |
xcopies(20,n=3) |
for (dx=[-20,0,20]) translate([dx,0,0]) |
zrot_copies(n=6,r=20) |
for (zr=[0:5]) rotate([0,0,zr*60]) translate([20,0,0]) |
skew(sxz=0.5,syz=0.333) |
multmatrix([[1,0,0.5,0],[0,1,0.333,0],[0,0,1,0],[0,0,0,1]]) |
BOSL2/shapes.scad Examples |
Raw OpenSCAD Equivalent |
---|---|
cube([10,20,30], anchor=BOTTOM); |
translate([0,0,15]) cube([10,20,30], center=true); |
cuboid([20,20,30], rounding=5); |
minkowski() {cube([10,10,20], center=true); sphere(r=5, $fn=32);} |
prismoid([30,40],[20,30],h=10); |
hull() {translate([0,0,0.005]) cube([30,40,0.01], center=true); translate([0,0,9.995]) cube([20,30,0.01],center=true);} |
xcyl(l=20,d=4); |
rotate([0,90,0]) cylinder(h=20, d=4, center=true); |
cyl(l=100, d=40, rounding=5); |
translate([0,0,50]) minkowski() {cylinder(h=90, d=30, center=true); sphere(r=5);} |
Documentation
The full library docs can be found at https://github.com/revarbat/BOSL2/wiki
Description
The Belfry OpenScad Library, v2.0. An OpenSCAD library of shapes, masks, and manipulators to make working with OpenSCAD easier. BETA
Readme
BSD-2-Clause
34 MiB
Languages
OpenSCAD
99.5%
Python
0.3%
Shell
0.1%