diff options
author | Joshua Shreve <j.a.shreve@gmail.com> | 2021-07-16 20:53:57 -0400 |
---|---|---|
committer | Joshua Shreve <j.a.shreve@gmail.com> | 2021-07-16 20:53:57 -0400 |
commit | 2308d88617e77cf58414d01694de523970e60996 (patch) | |
tree | 46f4fec3a016600a3d7b4faab3daa81ef3da4a86 | |
parent | 3e15f8564a959c0dbe73f2e71d1c916c62eb3aea (diff) |
Added docker capabilities and profile including batch file execution. If there is expressed interest I can add a linux .sh file as well to simplify image and container/app creation. Also, minor fixes on print outputs regarding imports/exports.
-rw-r--r-- | build_docker.bat | 4 | ||||
-rw-r--r-- | docker/Dockerfile | 18 | ||||
-rw-r--r-- | src/dactyl_manuform.py | 37 | ||||
-rw-r--r-- | src/generate_configuration.py | 7 | ||||
-rw-r--r-- | src/helpers_cadquery.py | 7 | ||||
-rw-r--r-- | src/helpers_solid.py | 1 |
6 files changed, 52 insertions, 22 deletions
diff --git a/build_docker.bat b/build_docker.bat new file mode 100644 index 0000000..dbf14c7 --- /dev/null +++ b/build_docker.bat @@ -0,0 +1,4 @@ +docker build -t dactyl-keyboard -f docker/Dockerfile . +docker run --name DM-run -d -v "%cd%/src:/app/src" -v "%cd%/things:/app/things" dactyl-keyboard python3 -i dactyl_manuform.py +docker run --name DM-config -d -v "%cd%/src:/app/src" -v "%cd%/things:/app/things" dactyl-keyboard python3 -i generate_configuration.py +docker run --name DM-bash -d -ti -v "%cd%/src:/app/src" -v "%cd%/things:/app/things" dactyl-keyboard diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..9b43f7d --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,18 @@ +FROM mambaorg/micromamba:0.8.2 + +RUN apt-get update && \ + apt-get install -y libgl1-mesa-glx gcc bash && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /app +RUN micromamba install -y -n base -c conda-forge -c cadquery \ + python=3 \ + cadquery=master \ + numpy=1 \ + scipy=1 && \ + (rm /opt/conda/pkgs/cache/* || true) + +RUN pip3 install solidpython + + +WORKDIR /app/src
\ No newline at end of file diff --git a/src/dactyl_manuform.py b/src/dactyl_manuform.py index b79c1fb..6012fac 100644 --- a/src/dactyl_manuform.py +++ b/src/dactyl_manuform.py @@ -38,6 +38,11 @@ except Exception: # ENGINE = 'cadquery' print('Setting Current Engine = {}'.format(ENGINE)) +if save_dir in ['', None, '.']: + save_path = os.path.join(r"..", "things") +else: + save_path = os.path.join(r"..", "things", save_dir) + ############################################### # END EXTREMELY UGLY BOOTSTRAP ############################################### @@ -135,9 +140,9 @@ screw_insert_bottom_radius = 5.31 / 2 screw_insert_top_radius = 5.1 / 2 -spath = path.join("..", "things", save_dir) -if not path.isdir(spath): - os.mkdir(spath) +# save_path = path.join("..", "things", save_dir) +if not path.isdir(save_path): + os.mkdir(save_path) def column_offset(column: int) -> list: @@ -2635,40 +2640,40 @@ def baseplate(): def run(): mod_r = model_side(side="right") - export_file(shape=mod_r, fname=path.join(r"..", "things", save_dir, config_name + r"_right")) + export_file(shape=mod_r, fname=path.join(save_path, config_name + r"_right")) if symmetry == "asymmetric": mod_l = model_side(side="left") - export_file(shape=mod_l, fname=path.join(r"..", "things", save_dir, config_name + r"_left")) + export_file(shape=mod_l, fname=path.join(save_path, config_name + r"_left")) else: - export_file(shape=mirror(mod_r, 'YZ'), fname=path.join(r"..", "things", save_dir, config_name + r"_left")) + export_file(shape=mirror(mod_r, 'YZ'), fname=path.join(save_path, config_name + r"_left")) base = baseplate() - export_file(shape=base, fname=path.join(r"..", "things", save_dir, config_name + r"_right_plate")) - export_dxf(shape=base, fname=path.join(r"..", "things", save_dir, config_name + r"_right_plate")) + export_file(shape=base, fname=path.join(save_path, config_name + r"_right_plate")) + export_dxf(shape=base, fname=path.join(save_path, config_name + r"_right_plate")) lbase = mirror(base, 'YZ') - export_file(shape=lbase, fname=path.join(r"..", "things", save_dir, config_name + r"_left_plate")) - export_dxf(shape=lbase, fname=path.join(r"..", "things", save_dir, config_name + r"_left_plate")) + export_file(shape=lbase, fname=path.join(save_path, config_name + r"_left_plate")) + export_dxf(shape=lbase, fname=path.join(save_path, config_name + r"_left_plate")) if oled_mount_type == 'UNDERCUT': - export_file(shape=oled_undercut_mount_frame()[1], fname=path.join(r"..", "things", save_dir, config_name + r"_oled_undercut_test")) + export_file(shape=oled_undercut_mount_frame()[1], fname=path.join(save_path, config_name + r"_oled_undercut_test")) if oled_mount_type == 'SLIDING': - export_file(shape=oled_sliding_mount_frame()[1], fname=path.join(r"..", "things", save_dir, config_name + r"_oled_sliding_test")) + export_file(shape=oled_sliding_mount_frame()[1], fname=path.join(save_path, config_name + r"_oled_sliding_test")) if oled_mount_type == 'CLIP': oled_mount_location_xyz = (0.0, 0.0, -oled_mount_depth / 2) oled_mount_rotation_xyz = (0.0, 0.0, 0.0) - export_file(shape=oled_clip(), fname=path.join(r"..", "things", save_dir, config_name + r"_oled_clip")) + export_file(shape=oled_clip(), fname=path.join(save_path, config_name + r"_oled_clip")) export_file(shape=oled_clip_mount_frame()[1], - fname=path.join(r"..", "things", save_dir, config_name + r"_oled_clip_test")) + fname=path.join(save_path, config_name + r"_oled_clip_test")) export_file(shape=union((oled_clip_mount_frame()[1], oled_clip())), - fname=path.join(r"..", "things", save_dir, config_name + r"_oled_clip_assy_test")) + fname=path.join(save_path, config_name + r"_oled_clip_assy_test")) # base = baseplate() -# export_file(shape=base, fname=path.join(r"..", "things", save_dir, config_name + r"_plate")) +# export_file(shape=base, fname=path.join(save_path, config_name + r"_plate")) if __name__ == '__main__': run()
\ No newline at end of file diff --git a/src/generate_configuration.py b/src/generate_configuration.py index b7344f2..2c2d7e7 100644 --- a/src/generate_configuration.py +++ b/src/generate_configuration.py @@ -29,7 +29,7 @@ shape_config = { 'centerrow_offset': 3, # rows from max, controls front_back tilt 'tenting_angle': pi / 12.0, # or, change this for more precise tenting control - # symmetry states if it is a symmetric or asymmetric build. If asymmetric it doubles the generation time. + # symmetry states if it is a symmetric or asymmetric bui. If asymmetric it doubles the generation time. 'symmetry': "symmetric", # "asymmetric" or "symmetric" 'column_style_gt5': "orthographic", @@ -278,6 +278,7 @@ shape_config = { #################################### def save_config(): + print("Saving Configuration") with open('run_config.json', mode='w') as fid: json.dump(shape_config, fid, indent=4) @@ -295,5 +296,5 @@ def update_config(fname, fname_out=None): if __name__ == '__main__': save_config() - from dactyl_manuform import * - run()
\ No newline at end of file + # from dactyl_manuform import * + # run()
\ No newline at end of file diff --git a/src/helpers_cadquery.py b/src/helpers_cadquery.py index 78069d6..44553e6 100644 --- a/src/helpers_cadquery.py +++ b/src/helpers_cadquery.py @@ -176,14 +176,15 @@ def extrude_poly(outer_poly, inner_polys=None, height=1): # vector=(0,0,1)): cq.Solid.extrudeLinear(outerWire=outer_wires, innerWires=inner_wires, vecNormal=cq.Vector(0, 0, height))) -def import_file(filename): +def import_file(fname): + print("IMPORTING FROM {}".format(fname)) return cq.Workplane('XY').add(cq.importers.importShape( cq.exporters.ExportTypes.STEP, - filename + ".step")) + fname + ".step")) def export_file(shape, fname): - print("IMPORTING FROM {}".format(fname)) + print("EXPORTING TO {}".format(fname)) cq.exporters.export(w=shape, fname=fname + ".step", exportType='STEP') diff --git a/src/helpers_solid.py b/src/helpers_solid.py index c98743c..470d5e8 100644 --- a/src/helpers_solid.py +++ b/src/helpers_solid.py @@ -129,4 +129,5 @@ def export_file(shape, fname): def export_dxf(shape, fname): + print("NO DXF EXPORT FOR SOLID".format(fname)) pass
\ No newline at end of file |