add `grid` and `round_box`
This commit is contained in:
parent
b84eb1cdf1
commit
83f30a3d8d
|
@ -0,0 +1,2 @@
|
|||
__pycache__/
|
||||
solidLib.egg-info/
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2021 Patrick Nisble (@acereca)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -1,3 +1,11 @@
|
|||
# solidLib
|
||||
|
||||
A Collection of solidpython functions, helpers etc
|
||||
|
||||
## Content
|
||||
|
||||
- `solidLib.primitives`
|
||||
- `round_box(x: float, y: float, z: float, r: float)`
|
||||
|
||||
- `solidLib.assortment`
|
||||
- `grid(x: float, y: float, w: float = 3, h: float = 1.5, fillet: bool = False, dim: float = 59)`
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
numpy>=1.19
|
||||
solidpython>=1.0
|
|
@ -0,0 +1,16 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
from distutils.core import setup
|
||||
|
||||
setup(
|
||||
name="solidLib",
|
||||
description="Collection of solidpython tools.",
|
||||
author="Patrick Nisble",
|
||||
author_email="acereca@outlook.de",
|
||||
url="https://git.acereca.net/acereca/solidLib",
|
||||
version="0.0.1",
|
||||
install_requires=[
|
||||
'numpy>=1.19',
|
||||
'solidpython>=1.0'
|
||||
]
|
||||
)
|
|
@ -0,0 +1 @@
|
|||
from .globals import SEGMENTS
|
|
@ -0,0 +1,38 @@
|
|||
import solid as scad
|
||||
from .globals import *
|
||||
|
||||
|
||||
def grid(
|
||||
x: float,
|
||||
y: float,
|
||||
w: float = 3,
|
||||
h: float = 1.5,
|
||||
fillet: bool = False,
|
||||
dim: float = 59,
|
||||
):
|
||||
|
||||
if w > h * 2:
|
||||
out = scad.polygon([[0, 0], [w / 2, 0], [w / 2 - h, h], [0, h]])
|
||||
else:
|
||||
out = scad.polygon([[0, 0], [w / 2, 0], [0, h]])
|
||||
out = scad.linear_extrude(dim)(out)
|
||||
out = scad.rotate([90, 0, 90])(out)
|
||||
|
||||
if fillet:
|
||||
scallop = scad.cube([dim - 2 * h - (w - 2 * h), 0.0001, 0.0001])
|
||||
scallop = scad.minkowski()(scallop, scad.sphere(r=h, segments=SEGMENTS))
|
||||
scallop += scad.rotate([0, -90, 0])(scallop) + scad.translate([dim - w, 0, 0])(
|
||||
scad.rotate([0, -90, 0])(scallop)
|
||||
)
|
||||
scallop = scad.translate([w / 2, w / 2, h])(scallop)
|
||||
out -= scallop
|
||||
|
||||
out += scad.translate([0, dim, 0])(scad.rotate([0, 0, -90])(out))
|
||||
out += scad.translate([dim, dim, 0])(scad.rotate([0, 0, 180])(out))
|
||||
|
||||
result = out
|
||||
for dx in range(x):
|
||||
for dy in range(y):
|
||||
result += scad.translate([dim * dx, dim * dy, 0])(out)
|
||||
|
||||
return result
|
|
@ -0,0 +1 @@
|
|||
SEGMENTS = 36
|
|
@ -0,0 +1,10 @@
|
|||
import solid as s
|
||||
import numpy as np
|
||||
from .globals import *
|
||||
|
||||
|
||||
def round_box(x, y, z, r):
|
||||
box = s.cube(np.array([x, y, z]) - r * 2)
|
||||
wall = s.sphere(r=r, segments=SEGMENTS)
|
||||
|
||||
return s.translate([r, r, r])(s.minkowski()(box, wall))
|
Loading…
Reference in New Issue