aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2024-01-10 15:49:07 -0600
committerToby Vincent <tobyv@tobyvin.dev>2024-01-10 15:49:07 -0600
commit99d12dc1fea358e4718fd551466b0fb4f4e13698 (patch)
tree5345fd193a721811f53e56342ec672ec3f8185d8
parent2959045de50bd14b0fa9e7774aa27b10c6e56f7c (diff)
Add build script and step2stl converter
-rw-r--r--.gitignore2
-rwxr-xr-xbuild.sh15
-rw-r--r--src/run_config.json2
-rwxr-xr-xstep2stl.py37
4 files changed, 55 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index fa26cc4..0e72c5c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,5 @@ things/*.step
things/*.stl
*.3mf
*.dxf
+
+*/.venv/*
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..4b46c43
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+export FREECADPATH="${FREECADPATH:-'/usr/lib/freecad/lib'}"
+
+CDPATH='' cd -- "$(dirname -- "$0")" || exit
+
+python -m venv src/.venv --system-site-package --upgrade-deps
+
+. src/.venv/bin/activate
+
+pip --require-virtualenv install numpy dataclasses-json scipy cadquery || exit
+
+(cd src && python -m dactyl_manuform) || exit
+
+./step2stl.py ../things/*.step
diff --git a/src/run_config.json b/src/run_config.json
index 34f3617..2158e8c 100644
--- a/src/run_config.json
+++ b/src/run_config.json
@@ -1,7 +1,7 @@
{
"ENGINE": "cadquery",
"save_dir": ".",
- "config_name": "tobyvin",
+ "config_name": "DM",
"show_caps": false,
"show_pcbs": false,
"nrows": 5,
diff --git a/step2stl.py b/step2stl.py
new file mode 100755
index 0000000..b947e82
--- /dev/null
+++ b/step2stl.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+
+import glob
+import os
+import sys
+
+sys.path.append("/usr/lib/freecad/lib")
+
+try:
+ import FreeCAD
+ import Mesh
+ import Part
+except ValueError as err:
+ print(err)
+
+
+def step2stl(step_file):
+ (name, _) = os.path.splitext(step_file)
+ part_name = "".join(s.title() for s in os.path.basename(name).split("_"))
+ stl_name = name + ".stl"
+
+ shape = Part.Shape()
+ shape.read(step_file)
+ doc = FreeCAD.newDocument("Doc")
+ pf = doc.addObject("Part::Feature", part_name)
+ pf.Shape = shape
+ Mesh.export([pf], stl_name)
+
+
+def main(argv):
+ for g in argv[1:]:
+ for step_file in glob.glob(g):
+ step2stl(step_file)
+
+
+if __name__ == "__main__":
+ main(sys.argv)