Skip to content

Commit 806819e

Browse files
authored
Merge pull request #47 from openbikesensor/scad-generator
Merge Scad generator to get the fixes back to MAIN
2 parents 43d9736 + 72dcef0 commit 806819e

52 files changed

Lines changed: 1126596 additions & 1066745 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ logo/*
66
!logo/OpenBikeSensor
77
!logo/template
88
!logo/README.md
9+
customizer/dist/*
10+
*.egg-info/
11+
venv/*
210 KB
Binary file not shown.
244 KB
Binary file not shown.

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from tiangolo/uvicorn-gunicorn-fastapi
2+
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y openscad make fonts-open-sans
3+
ADD . /case
4+
RUN pip3 install -e /case/customizer/
5+
ENV LOG_LEVEL=info
6+
ENV MODULE_NAME=obs_case_customizer.app

Makefile

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
OPENSCAD=/usr/bin/openscad
22
OPENSCAD_OPTIONS=-q
3+
STL_SORTER=lib/sort_stl.py
34
IMAGE_OPTIONS=--imgsize=1024,768 --colorscheme "Tomorrow Night" --render true -D orient_for_printing=false
45
THUMBNAIL_OPTIONS=--imgsize=400,300 --colorscheme "Tomorrow Night" --render true -D fast=true -D orient_for_printing=false
56

7+
SHELL=bash
8+
69
SRCS=$(wildcard src/*/*.scad)
710
STLS=$(patsubst src/%.scad,export/%.stl,$(SRCS))
811
PNGS=$(patsubst src/%.scad,render/%.png,$(SRCS))
@@ -26,6 +29,7 @@ clean:
2629
export/%.stl: src/%.scad
2730
@mkdir -p $(shell dirname $@)
2831
$(OPENSCAD) $(OPENSCAD_OPTIONS) -D orient_for_printing=true -o $@ $<
32+
$(STL_SORTER) $@
2933

3034
export-all : $(STLS)
3135

@@ -50,10 +54,10 @@ render/assembly.gif: assembly.scad $(SRCS)
5054
# $3: logo part (main|highlight)
5155
# $4: logo mode (normal|inverted)
5256
define logo-part-rule
53-
export/logo/$(1)/$(shell basename $(2))-$(4)-$(3).stl: src/$(2).scad logo/$(1)/$(shell basename $(2)).svg
57+
export/logo/$(1)/$(shell basename $(2))-$(4)-$(3).stl: src/$(2).scad logo/$(1)/$(shell basename $(2)).svg export/$(2).stl
5458
@mkdir -p $$(shell dirname $$@)
55-
$$(OPENSCAD) $$(OPENSCAD_OPTIONS) -D orient_for_printing=true -D logo_enabled=true -D 'logo_mode="$(4)"' -D 'logo_part="$(3)"' -D 'logo_name="$(1)"' -o $$@ $$<
56-
59+
$$(OPENSCAD) $$(OPENSCAD_OPTIONS) -D orient_for_printing=true -D logo_enabled=true -D logo_use_prebuild=true -D 'logo_mode="$(4)"' -D 'logo_part="$(3)"' -D 'logo_name="$(1)"' -o $$@ $$<
60+
$$(STL_SORTER) $$@
5761
logo-$1-$4: export/logo/$(1)/$(shell basename $(2))-$(4)-$(3).stl
5862
logo-$1: export/logo/$(1)/$(shell basename $(2))-$(4)-$(3).stl
5963
logos: logo-$1
@@ -78,3 +82,14 @@ endef
7882

7983
$(foreach file,$(FILES_WITH_LOGO), \
8084
$(eval $(call logo-template-rule,$(file))))
85+
86+
87+
define numbered-cover-rule
88+
export/Mounting/AttachmentCover_$(1).stl: src/Mounting/AttachmentCover.scad
89+
@mkdir -p $$(shell dirname $$@)
90+
$(OPENSCAD) $(OPENSCAD_OPTIONS) -D orient_for_printing=true -D attachment_cover_number_text=$(1) -o $$@ $$<
91+
$(STL_SORTER) $@
92+
endef
93+
94+
$(foreach number,$(shell seq 0 1 100), \
95+
$(eval $(call numbered-cover-rule,$(number))))

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,19 @@ native format of your CAD software on top.
345345

346346
OpenSCAD is a special case of course: Here submitting `.stl` (for now) and the
347347
`.scad` file is sufficient.
348+
349+
350+
### Customizer webservice
351+
352+
To run the customizer webservice you run it from the dockerfile:
353+
354+
```
355+
docker build . -t customizer
356+
docker run --rm -p 8001:80 customizer
357+
```
358+
359+
Whereafter you should be able to access your customizer on your host on port 8001.
360+
361+
Alternatively you can launch the python module directly using uvicorn,
362+
but that is only recommended for dev setups an d will be described
363+
in the module readme.

customizer/LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2022 The OpenBikeSensor Project
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

customizer/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
OpenBikeSensor3DPrintableCase Customizer
2+
========================================
3+
4+
Run it in Docker yeah

customizer/setup.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import setuptools
2+
3+
with open("README.md", "r", encoding="utf-8") as fh:
4+
long_description = fh.read()
5+
6+
setuptools.setup(
7+
name="openbikesensor-case-customizer",
8+
version="0.0.1",
9+
author="gluap",
10+
author_email="github@pgoergen.de",
11+
description="OpenBikesSensor 3D Printable Case customizer",
12+
long_description=long_description,
13+
long_description_content_type="text/markdown",
14+
url="https://github.com/openbikesensor/OpenBikeSensor3dPrintableCase",
15+
project_urls={
16+
"Bug Tracker": "https://github.com/openbikesensor/OpenBikeSensor3dPrintableCase/issues",
17+
},
18+
classifiers=[
19+
"Programming Language :: Python :: 3",
20+
"License :: OSI Approved :: MIT License",
21+
"Operating System :: OS Independent",
22+
],
23+
package_dir={"": "src"},
24+
packages=setuptools.find_packages(where="src"),
25+
python_requires=">=3.6",
26+
install_requires=[
27+
"fastapi",
28+
"python-multipart",
29+
"jinja2",
30+
"pyyaml",
31+
"pydantic",
32+
"sse_starlette",
33+
"websockets",
34+
"uvicorn"
35+
]
36+
)

0 commit comments

Comments
 (0)