From 79e051356a6b247d724d241b0f77bb00fdcf99a9 Mon Sep 17 00:00:00 2001 From: Edward Date: Mon, 23 Aug 2021 12:42:50 -0400 Subject: [PATCH 01/10] added run.py as main entry point modularized generate_configuration, and updated Dockerfile and run.sh to work with the new run.py script --- docker/Dockerfile | 4 +- run.py | 53 +++++ run.sh | 86 +------ src/argument_parser.py | 60 +++++ src/default_configuration.py | 375 ++++++++++++++++++++++++++++++ src/generate_configuration.py | 423 ++-------------------------------- 6 files changed, 519 insertions(+), 482 deletions(-) create mode 100644 run.py create mode 100644 src/argument_parser.py create mode 100644 src/default_configuration.py diff --git a/docker/Dockerfile b/docker/Dockerfile index 9b43f7d5d..15d06b3b6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,7 +4,6 @@ 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 \ @@ -14,5 +13,4 @@ RUN micromamba install -y -n base -c conda-forge -c cadquery \ RUN pip3 install solidpython - -WORKDIR /app/src \ No newline at end of file +WORKDIR /app \ No newline at end of file diff --git a/run.py b/run.py new file mode 100644 index 000000000..24e4deec6 --- /dev/null +++ b/run.py @@ -0,0 +1,53 @@ +import os.path as path +import getopt, sys +import src.argument_parser as parser + +args = parser.parse() + +if len(args['args']) < 1: + print("A command must be specified") + sys.exit(1) + +command = args['args'][0] +if command not in ('help', 'generate', 'configure', 'realease'): + print("Invalid command. Try 'help'") + sys.exit(1) + +def show_usage(): + print("Dactyl-Manuform Keyboard Generator") + print("") + print("Use this tool to configure and generate files for building a keyboard.") + print("") + print("") + print("Usage:") + print(" run.py [-d|--debug] [-u|--update] [--config ] ") + print("") + print("Available Commands:") + print(" help Show this help") + print(" release Run model_builder.py") + print(" generate Output the keyboard files to the './things' directory") + print(" configure Generate a configuration file with default values. The config") + print(" file will be saved to configs/. If the") + print(" --config flag is not set, the default config_name will be used.") + print("") + print("Flags:") + print(" --config Set the configuration file to use, relative to the './configs'") + print(" directory.") + print(" -u|--update Update a config file. This flag must be set if the config file") + print(" already exists.") + print(" -d|--debug Show debug output") + print("") + +if command == 'help': + show_usage() +elif command == 'generate': + import src.dactyl_manuform as command + command.run(args) +elif command == 'configure': + import src.generate_configuration as command + command.save_config(args) +elif command == 'release': + import src.model_builder as command + command.run() + + diff --git a/run.sh b/run.sh index ad6a9227d..a5ca8a8a2 100755 --- a/run.sh +++ b/run.sh @@ -3,17 +3,12 @@ cd "${0%/*}" || exit 1 - # set the default Docker image tag to dactyl-keyboard IMAGE_TAG="dactyl-keyboard" # by default, don't rebuild the image REBUILD=false; -# leave config empty to use default values -CONFIG="" - - # check for command line flags while test $# -gt 0; do case "$1" in @@ -30,96 +25,37 @@ while test $# -gt 0; do exit 1 fi ;; - -c|--config) - CONFIG=$2 - shift 2 - ;; - -*|--*) - echo "Error: Unknown flag $1" >&2 - exit 1 - ;; *) - COMMAND=$1 + # build a command string to pass to run.py + COMMAND="$COMMAND $1" shift; ;; esac done - -case $COMMAND in - help) - echo "Dactyl-Manuform Keyboard Generator" - echo "" - echo "Use this tool to configure and generate files for building a keyboard. All" - echo "commands will be run in a Docker contianer, which will be built if it does" - echo "not already exist." - echo "" - echo "" - echo "Usage:" - echo " run [-r] [-i ] [-c ] " - echo "" - echo "Available Commands:" - echo " help Show this help" - echo " build Rebuild the docker image" - echo " release Run model_builder.py" - echo " generate Output the keyboard files to the './things' directory" - echo " configure Generate a configuration file with default values. The config" - echo " file will be saved to configs/.json. If the" - echo " -c flag is not set, the defailt config_name will be used." - echo "" - echo "Flags:" - echo " -c Set the configuration file to use. This should be the name of the file" - echo " only, without a file extension, and it is relative to the './configs'" - echo " directory. For example, '-c my-custom-dm' will refer to a file located" - echo " at './configs/my-custom-dm.json'" - echo " -r Rebuild the docker image" - echo " -t The tag that should be applied to the docker image" - exit 0 - ;; - build) - docker build -t ${IMAGE_TAG} -f docker/Dockerfile . - exit 0 - ;; - generate) - SCRIPT=dactyl_manuform.py - ;; - configure) - SCRIPT=generate_configuration.py - ;; - release) - SCRIPT=model_builder.py - ;; - *) - echo "Invalid command. Try 'run help'" - exit 1 -esac - - # get the image ID, and save the return code so we'll know if the image exists IMAGE_ID=$(docker inspect --type=image --format={{.Id}} ${IMAGE_TAG}) INSPECT_RETURN_CODE=$? + # if we were specifically told to rebuild, or if the image doesn't exists, then build the docker image if $REBUILD || [ $INSPECT_RETURN_CODE -ne 0 ]; then docker build -t ${IMAGE_TAG} -f docker/Dockerfile . fi -# if a config file was specified, set the command line argument for the python script -if [[ ! -z $CONFIG ]]; then - CONFIG_OPTION="--config=${CONFIG}" -fi - -# run the command in a temporary container -docker run --name dm-run -d --rm -v "`pwd`/src:/app/src" -v "`pwd`/things:/app/things" -v "`pwd`/configs:/app/configs" ${IMAGE_TAG} python3 $SCRIPT $CONFIG_OPTION > /dev/null 2>&1 +# run the command in a container +docker run --name dm-run -d -v "`pwd`:/app" ${IMAGE_TAG} python3 run.py $COMMAND > /dev/null 2>&1 # show progress indicator while until dm-run container completes -while $(docker inspect --format={{.Id}} dm-run > /dev/null 2>&1); do +while [ "$(docker inspect --format={{.State.Status}} dm-run)" != 'exited' ]; do echo -n "." sleep 1.5 done -echo "" -echo "Dactyl-Manuform '${COMMAND}' is complete!" -echo "" \ No newline at end of file +# display the output of run.py +docker logs dm-run + +# remove the container +docker rm dm-run > /dev/null 2>&1 \ No newline at end of file diff --git a/src/argument_parser.py b/src/argument_parser.py new file mode 100644 index 000000000..ec4427bd8 --- /dev/null +++ b/src/argument_parser.py @@ -0,0 +1,60 @@ +import os.path as path +import getopt, sys + +def parse(): + # set defaults + debug = False + update = False + config_name = 'DM' + relative_path = r"."; + file_name = "run_config" + format = 'json' + absolute_path = path.abspath(path.join(__file__, r"..", relative_path, file_name + r"." + format)) + + opts, args = getopt.getopt(sys.argv[1:], "ud", ["config=", "update", "debug"]) + for opt, arg in opts: + if opt in ('--config'): + config_path_parts = arg.split(r'/') + file_parts = config_path_parts.pop().split(r'.') + + file_name = file_parts[0] + if len(file_parts) == 2: + format = file_parts[1] + + config_name = file_name + + if len(config_path_parts) > 0: + relative_path = path.join(*config_path_parts) + + absolute_path = path.abspath(path.join(__file__, r"..", r"..", "configs", relative_path, file_name + r"." + format)) + elif opt in ('-u', "--update"): + update = True + elif opt in ('-d', "--debug"): + debug = True + + + if debug: + print("CONFIG OPTIONS") + print("config.name: " + config_name) + print("config.relative_path: " + relative_path) + print("config.file_name: " + file_name) + print("config.format: " + format) + print("config.absolute_path: " + absolute_path) + print("update: " + str(update)) + print("opts: " + str(opts)) + print("args: " + str(args)) + print("") + + return { + 'config': { + 'name': config_name, + 'relative_path': relative_path, + 'file_name': file_name, + 'format': format, + 'absolute_path': absolute_path + }, + 'debug': debug, + 'update': update, + 'opts': opts, + 'args': args + } \ No newline at end of file diff --git a/src/default_configuration.py b/src/default_configuration.py new file mode 100644 index 000000000..843c06986 --- /dev/null +++ b/src/default_configuration.py @@ -0,0 +1,375 @@ +pi = 3.14159 +d2r = pi / 180 + +shape_config = { + + 'ENGINE': 'solid', # 'solid' = solid python / OpenSCAD, 'cadquery' = cadquery / OpenCascade + # 'ENGINE': 'cadquery', # 'solid' = solid python / OpenSCAD, 'cadquery' = cadquery / OpenCascade + + + ###################### + ## Shape parameters ## + ###################### + + 'save_dir': '.', + 'config_name': "DM", + + 'show_caps': True, + 'show_pcbs': False, #only runs if caps are shown, easist place to initially inject geometry + + 'nrows': 5, #5, # key rows + 'ncols': 6, #6, # key columns + + 'alpha': pi / 12.0, # curvature of the columns + 'beta': pi / 36.0, # curvature of the rows + 'centercol': 3, # controls left_right tilt / tenting (higher number is more tenting) + '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 bui. If asymmetric it doubles the generation time. + 'symmetry': "symmetric", # "asymmetric" or "symmetric" + + 'column_style_gt5': "orthographic", + 'column_style': "standard", # options include :standard, :orthographic, and :fixed + + 'thumb_offsets': [6, -3, 7], + 'keyboard_z_offset': ( + 11 # controls overall height# original=9 with centercol=3# use 16 for centercol=2 + ), + + ############################## + # THUMB PARAMETERS + ############################## + # 'DEFAULT' 6-key, 'MINI' 5-key, 'CARBONFET' 6-key, 'MINIDOX' 3-key, 'TRACKBALL_ORBYL', 'TRACKBALL_CJ' + 'thumb_style': 'TRACKBALL_CJ', + 'default_1U_cluster': True, # only used with default, makes top right thumb cluster key 1U + # Thumb key size. May need slight oversizing, check w/ caps. Additional spacing will be automatically added for larger keys. + 'minidox_Usize': 1.6, + # Thumb plate rotations, anything other than 90 degree increments WILL NOT WORK. + 'thumb_plate_tr_rotation': 0.0, # Top right plate rotation tweaks as thumb cluster is crowded for hot swap, etc. + 'thumb_plate_tl_rotation': 0.0, # Top left plate rotation tweaks as thumb cluster is crowded for hot swap, etc. + 'thumb_plate_mr_rotation': 0.0, # Mid right plate rotation tweaks as thumb cluster is crowded for hot swap, etc. + 'thumb_plate_ml_rotation': 0.0, # Mid left plate rotation tweaks as thumb cluster is crowded for hot swap, etc. + 'thumb_plate_br_rotation': 0.0, # Bottom right plate rotation tweaks as thumb cluster is crowded for hot swap, etc. + 'thumb_plate_bl_rotation': 0.0, # Bottom right plate rotation tweaks as thumb cluster is crowded for hot swap, etc. + + ################################### + ## Trackball in Wall ## + ################################### + 'trackball_in_wall': False, # Separate trackball option, placing it in the OLED area + 'tbiw_ball_center_row': 0.2, # up from cornerrow instead of down from top + 'tbiw_translational_offset': (0.0, 0.0, 0.0), + 'tbiw_rotation_offset': (0.0, 0.0, 0.0), + 'tbiw_left_wall_x_offset_override': 50.0, + 'tbiw_left_wall_z_offset_override': 0.0, + 'tbiw_left_wall_lower_y_offset': 0.0, + 'tbiw_left_wall_lower_z_offset': 0.0, + + 'tbiw_oled_center_row': .75, # not none, offsets are from this position + 'tbiw_oled_translation_offset': (-3.5, 0, 1.5), # Z offset tweaks are expected depending on curvature and OLED mount choice. + 'tbiw_oled_rotation_offset': (0, 0, 0), + + ########################################### + ## Trackball JS / ORBYL Thumb Cluster ## + ########################################## + 'other_thumb': 'DEFAULT', # cluster used for second thumb except if ball_side == 'both' + 'tbjs_key_diameter': 70, + # Offsets are per key and are applied before rotating into place around the ball + # X and Y act like Tangential and Radial around the ball + 'tbjs_translation_offset': (0, 0, 10), # applied to the whole assy + 'tbjs_rotation_offset': (0, 0, 0), # applied to the whole assy + 'tbjs_key_translation_offsets': [ + (0.0, 0.0, -3.0-5), + (0.0, 0.0, -3.0-5), + (0.0, 0.0, -3.0-5), + (0.0, 0.0, -3.0-5), + ], + 'tbjs_key_rotation_offsets': [ + (0.0, 0.0, 0.0), + (0.0, 0.0, 0.0), + (0.0, 0.0, 0.0), + (0.0, 0.0, 0.0), + ], + + ################################### + ## Trackball CJ Thumb Cluster ## + ################################### + 'tbcj_inner_diameter': 42, + 'tbcj_thickness': 2, + 'tbcj_outer_diameter': 53, + + + ################################### + ## Trackball General ## + ################################### + # EXPERIMENTAL + 'trackball_modular': False, # May add removable trackball in subsequent releases, no current use. + # END EXPERIMENTAL + + 'trackball_Usize': 1.5, # size for inner key near trackball + 'ball_side': 'right', #'left', 'right', or 'both' + 'ball_diameter': 34.0, + 'ball_wall_thickness': 3, # should not be changed unless the import models are changed. + 'ball_gap': 1.0, + 'trackball_hole_diameter': 36.5, + 'trackball_hole_height': 40, + 'trackball_plate_thickness': 2, + 'trackball_plate_width': 2, + # Removed trackball_rotation, ball_z_offset. and trackball_sensor_rotation and added more flexibility. + 'tb_socket_translation_offset': (0, 0, 2.0), # applied to the socket and sensor, large values will cause web/wall issues. + 'tb_socket_rotation_offset': (0, 0, 0), # applied to the socket and sensor, large values will cause web/wall issues. + 'tb_sensor_translation_offset': (0, 0, 0), #deviation from socket offsets, for fixing generated geometry issues + 'tb_sensor_rotation_offset': (0, 0, 0), #deviation from socket offsets, for changing the sensor roll orientation + + ############################## + # EXPERIMENTAL PARAMETERS + ############################## + 'pinky_1_5U': False, # LEAVE AS FALSE, CURRENTLY BROKEN + 'first_1_5U_row': 0, + 'last_1_5U_row': 5, + ############################## + + + 'extra_width': 2.5, # extra space between the base of keys# original= 2 + 'extra_height': 1.0, # original= 0.5 + + 'wall_z_offset': 15, # length of the first downward_sloping part of the wall + 'wall_x_offset': 5, # offset in the x and/or y direction for the first downward_sloping part of the wall (negative) + 'wall_y_offset': 6, # offset in the x and/or y direction for the first downward_sloping part of the wall (negative) + 'left_wall_x_offset': 12, # specific values for the left side due to the minimal wall. + 'left_wall_z_offset': 3, # specific values for the left side due to the minimal wall. + 'left_wall_lower_y_offset': 0, # specific values for the lower left corner. + 'left_wall_lower_z_offset': 0, + 'wall_thickness': 4.5, # wall thickness parameter used on upper/mid stage of the wall + 'wall_base_y_thickness': 4.5, # wall thickness at the lower stage + 'wall_base_x_thickness': 4.5, # wall thickness at the lower stage + + 'wall_base_back_thickness': 4.5, # wall thickness at the lower stage in the specifically in back for interface. + + ## Settings for column_style == :fixed + ## The defaults roughly match Maltron settings + ## http://patentimages.storage.googleapis.com/EP0219944A2/imgf0002.png + ## fixed_z overrides the z portion of the column ofsets above. + ## NOTE: THIS DOESN'T WORK QUITE LIKE I'D HOPED. + 'fixed_angles': [d2r * 10, d2r * 10, 0, 0, 0, d2r * -15, d2r * -15], + 'fixed_x': [-41.5, -22.5, 0, 20.3, 41.4, 65.5, 89.6], # relative to the middle finger + 'fixed_z': [12.1, 8.3, 0, 5, 10.7, 14.5, 17.5], + 'fixed_tenting': d2r * 0, + + ################# + ## Switch Hole ## + ################# + + # plate options are + # 'HOLE' = a square hole. Also useful for applying custom plate files. + # 'NUB' = original side nubs. + # 'UNDERCUT' = snap fit undercut. May require CLIP_THICKNESS and possibly CLIP_UNDERCUT tweaking + # and/or filing to get proper snap. + # 'NOTCH' = snap fit undercut only near switch clip. May require CLIP_THICKNESS and possibly CLIP_UNDERCUT + # tweaking and/or filing to get proper snap. + # 'HS_NUB' = hot swap underside with nubs. + # 'HS_UNDERCUT' = hot swap underside with undercut. Does not generate properly. Hot swap step needs to be modified. + # 'HS_NOTCH' = hot swap underside with notch. Does not generate properly. Hot swap step needs to be modified. + # 'plate_style': 'NUB', + 'plate_style': 'NOTCH', + + 'hole_keyswitch_height': 14.0, + 'hole_keyswitch_width': 14.0, + + 'nub_keyswitch_height': 14.4, + 'nub_keyswitch_width': 14.4, + + 'undercut_keyswitch_height': 14.0, + 'undercut_keyswitch_width': 14.0, + 'notch_width': 5.0, # If using notch, it is identical to undecut, but only locally by the switch clip + + 'sa_profile_key_height': 12.7, + 'sa_length': 18.5, + 'sa_double_length': 37.5, + 'plate_thickness': 4+1.1, + + 'plate_rim': 1.5 + 0.5, + # Undercut style dimensions + 'clip_thickness': 1.4, + 'clip_undercut': 1.0, + 'undercut_transition': .2, # NOT FUNCTIONAL WITH OPENSCAD, ONLY WORKS WITH CADQUERY + + # Custom plate step file + 'plate_file': None, + 'plate_offset': 0.0, + + ########################## + ## OLED Mount Location + ########################## + # Initial pass will be manual placement. Can be used to create other mounts as well. + # Mount type options: + # None or 'NONE' = No OLED mount + # 'UNDERCUT' = Simple rectangle with undercut for clip in item + # 'SLIDING' = Features to slide the OLED in place and use a pin or block to secure from underneath. + # 'CLIP' = Features to set the OLED in a frame a snap a bezel down to hold it in place. + + 'oled_mount_type': 'CLIP', + 'oled_center_row': 1.25, # if not None, this will override the oled_mount_location_xyz and oled_mount_rotation_xyz settings + 'oled_translation_offset': (0, 0, 4), # Z offset tweaks are expected depending on curvature and OLED mount choice. + 'oled_rotation_offset': (0, 0, 0), + + 'oled_configurations': { + 'UNDERCUT':{ + # Common parameters + 'oled_mount_width': 15.0, + 'oled_mount_height': 35.0, + 'oled_mount_rim': 3.0, + 'oled_mount_depth': 6.0, + 'oled_mount_cut_depth': 20.0, + 'oled_mount_location_xyz': (-80.0, 20.0, 45.0), # will be overwritten if oled_center_row is not None + 'oled_mount_rotation_xyz': (13.0, 0.0, -6.0), # will be overwritten if oled_center_row is not None + 'oled_left_wall_x_offset_override': 28.0, + 'oled_left_wall_z_offset_override': 0.0, + 'oled_left_wall_lower_y_offset': 12.0, + 'oled_left_wall_lower_z_offset': 5.0, + + # 'UNDERCUT' Parameters + 'oled_mount_undercut': 1.0, + 'oled_mount_undercut_thickness': 2.0, + }, + 'SLIDING': { + # Common parameters + 'oled_mount_width': 12.5, # width of OLED, plus clearance + 'oled_mount_height': 25.0, # length of screen + 'oled_mount_rim': 2.5, + 'oled_mount_depth': 8.0, + 'oled_mount_cut_depth': 20.0, + 'oled_mount_location_xyz': (-78.0, 10.0, 41.0), # will be overwritten if oled_center_row is not None + 'oled_mount_rotation_xyz': (6.0, 0.0, -3.0), # will be overwritten if oled_center_row is not None + 'oled_left_wall_x_offset_override': 24.0, + 'oled_left_wall_z_offset_override': 0.0, + 'oled_left_wall_lower_y_offset': 12.0, + 'oled_left_wall_lower_z_offset': 5.0, + + # 'SLIDING' Parameters + 'oled_thickness': 4.2, # thickness of OLED, plus clearance. Must include components + 'oled_edge_overlap_end': 6.5, # length from end of viewable screen to end of PCB + 'oled_edge_overlap_connector': 5.5, # length from end of viewable screen to end of PCB on connection side. + 'oled_edge_overlap_thickness': 2.5, # thickness of material over edge of PCB + 'oled_edge_overlap_clearance': 2.5, # Clearance to insert PCB before laying down and sliding. + 'oled_edge_chamfer': 2.0, + }, + 'CLIP': { + # Common parameters + 'oled_mount_width': 12.5, # whole OLED width + 'oled_mount_height': 39.0, # whole OLED length + 'oled_mount_rim': 2.0, + 'oled_mount_depth': 7.0, + 'oled_mount_cut_depth': 20.0, + 'oled_mount_location_xyz': (-78.0, 20.0, 42.0), # will be overwritten if oled_center_row is not None + 'oled_mount_rotation_xyz': (12.0, 0.0, -6.0), # will be overwritten if oled_center_row is not None + 'oled_left_wall_x_offset_override': 24.0, + 'oled_left_wall_z_offset_override': 0.0, + 'oled_left_wall_lower_y_offset': 12.0, + 'oled_left_wall_lower_z_offset': 5.0, + + # 'CLIP' Parameters + 'oled_thickness': 4.2, # thickness of OLED, plus clearance. Must include components + 'oled_mount_bezel_thickness': 3.5, # z thickness of clip bezel + 'oled_mount_bezel_chamfer': 2.0, # depth of the 45 degree chamfer + 'oled_mount_connector_hole': 6.0, + 'oled_screen_start_from_conn_end': 6.5, + 'oled_screen_length': 24.5, + 'oled_screen_width': 10.5, + 'oled_clip_thickness': 1.5, + 'oled_clip_width': 6.0, + 'oled_clip_overhang': 1.0, + 'oled_clip_extension': 5.0, + 'oled_clip_width_clearance': 0.5, + 'oled_clip_undercut': 0.5, + 'oled_clip_undercut_thickness': 2.5, + 'oled_clip_y_gap': .2, + 'oled_clip_z_gap': .2, + } + }, + 'web_thickness': 4.0, + 'post_size': 0.1, + # post_adj': post_size / 2 + 'post_adj': 0, + 'screws_offset': 'INSIDE', #'OUTSIDE', 'INSIDE', 'ORIGINAL' + + 'screw_insert_height': 3.8, + 'screw_insert_bottom_radius': 5.31 / 2, + 'screw_insert_top_radius': 5.1 / 2, + + # Does anyone even use these? I think they just get in the way. + 'wire_post_height': 7, + 'wire_post_overhang': 3.5, + 'wire_post_diameter': 2.6, + + + + + ################################### + ## Controller Mount / Connectors ## + ################################### + # connector options are + # 'RJ9_USB_WALL' = Standard internal plate with RJ9 opening and square cutout for connection. + # 'USB_WALL' = Standard internal plate with a square cutout for connection, no RJ9. + # 'RJ9_USB_TEENSY' = Teensy holder + # 'USB_TEENSY' = Teensy holder, no RJ9 + # 'EXTERNAL' = square cutout for a holder such as the one from lolligagger. + # 'NONE' = No openings in the back. + 'controller_mount_type': 'EXTERNAL', + + 'external_holder_height': 12.5, + 'external_holder_width': 28.75, + 'external_holder_xoffset': -5.0, + 'external_holder_yoffset': -4.5, #Tweak this value to get the right undercut for the tray engagement. + + # Offset is from the top inner corner of the top inner key. + + ################################### + ## Bottom Plate Dimensions + ################################### + # COMMON DIMENSION + 'screw_hole_diameter': 2, + # USED FOR CADQUERY ONLY + 'base_thickness': 3.0, # thickness in the middle of the plate + 'base_offset': 3.0, # Both start flat/flush on the bottom. This offsets the base up (if positive) + 'base_rim_thickness': 5.0, # thickness on the outer frame with screws + 'screw_cbore_diameter': 4.0, + 'screw_cbore_depth': 2.0, + + # Offset is from the top inner corner of the top inner key. + + ################################### + ## HOLES ON PLATE FOR PCB MOUNT + ################################### + 'plate_holes': False, + 'plate_holes_xy_offset': (0.0, 0.0), + 'plate_holes_width': 14.3, + 'plate_holes_height': 14.3, + 'plate_holes_diameter': 1.7, + 'plate_holes_depth': 20.0, + + ################################### + ## SHOW PCB FOR FIT CHECK + ################################### + 'pcb_width': 18.0, + 'pcb_height': 18.0, + 'pcb_thickness': 1.5, + 'pcb_hole_diameter': 2, + 'pcb_hole_pattern_width': 14.3, + 'pcb_hole_pattern_height': 14.3, + + ################################### + ## COLUMN OFFSETS + #################################### + + 'column_offsets': [ + [0, 0, 0], + [0, 0, 0], + [0, 2.82, -4.5], + [0, 0, 0], + [0, -6, 5],# REDUCED STAGGER + [0, -6, 5],# REDUCED STAGGER + [0, -6, 5],# NOT USED IN MOST FORMATS (7th column) + ], + +} \ No newline at end of file diff --git a/src/generate_configuration.py b/src/generate_configuration.py index 7b0ef8478..a88178a58 100644 --- a/src/generate_configuration.py +++ b/src/generate_configuration.py @@ -2,408 +2,23 @@ import getopt import os import json - - -pi = 3.14159 -d2r = pi / 180 -r2d = 180 / pi - -shape_config = { - - 'ENGINE': 'solid', # 'solid' = solid python / OpenSCAD, 'cadquery' = cadquery / OpenCascade - # 'ENGINE': 'cadquery', # 'solid' = solid python / OpenSCAD, 'cadquery' = cadquery / OpenCascade - - - ###################### - ## Shape parameters ## - ###################### - - 'save_dir': '.', - 'config_name': "DM", - - 'show_caps': True, - 'show_pcbs': False, #only runs if caps are shown, easist place to initially inject geometry - - 'nrows': 5, #5, # key rows - 'ncols': 6, #6, # key columns - - 'alpha': pi / 12.0, # curvature of the columns - 'beta': pi / 36.0, # curvature of the rows - 'centercol': 3, # controls left_right tilt / tenting (higher number is more tenting) - '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 bui. If asymmetric it doubles the generation time. - 'symmetry': "symmetric", # "asymmetric" or "symmetric" - - 'column_style_gt5': "orthographic", - 'column_style': "standard", # options include :standard, :orthographic, and :fixed - - 'thumb_offsets': [6, -3, 7], - 'keyboard_z_offset': ( - 11 # controls overall height# original=9 with centercol=3# use 16 for centercol=2 - ), - - ############################## - # THUMB PARAMETERS - ############################## - # 'DEFAULT' 6-key, 'MINI' 5-key, 'CARBONFET' 6-key, 'MINIDOX' 3-key, 'TRACKBALL_ORBYL', 'TRACKBALL_CJ' - 'thumb_style': 'TRACKBALL_CJ', - 'default_1U_cluster': True, # only used with default, makes top right thumb cluster key 1U - # Thumb key size. May need slight oversizing, check w/ caps. Additional spacing will be automatically added for larger keys. - 'minidox_Usize': 1.6, - # Thumb plate rotations, anything other than 90 degree increments WILL NOT WORK. - 'thumb_plate_tr_rotation': 0.0, # Top right plate rotation tweaks as thumb cluster is crowded for hot swap, etc. - 'thumb_plate_tl_rotation': 0.0, # Top left plate rotation tweaks as thumb cluster is crowded for hot swap, etc. - 'thumb_plate_mr_rotation': 0.0, # Mid right plate rotation tweaks as thumb cluster is crowded for hot swap, etc. - 'thumb_plate_ml_rotation': 0.0, # Mid left plate rotation tweaks as thumb cluster is crowded for hot swap, etc. - 'thumb_plate_br_rotation': 0.0, # Bottom right plate rotation tweaks as thumb cluster is crowded for hot swap, etc. - 'thumb_plate_bl_rotation': 0.0, # Bottom right plate rotation tweaks as thumb cluster is crowded for hot swap, etc. - - ################################### - ## Trackball in Wall ## - ################################### - 'trackball_in_wall': False, # Separate trackball option, placing it in the OLED area - 'tbiw_ball_center_row': 0.2, # up from cornerrow instead of down from top - 'tbiw_translational_offset': (0.0, 0.0, 0.0), - 'tbiw_rotation_offset': (0.0, 0.0, 0.0), - 'tbiw_left_wall_x_offset_override': 50.0, - 'tbiw_left_wall_z_offset_override': 0.0, - 'tbiw_left_wall_lower_y_offset': 0.0, - 'tbiw_left_wall_lower_z_offset': 0.0, - - 'tbiw_oled_center_row': .75, # not none, offsets are from this position - 'tbiw_oled_translation_offset': (-3.5, 0, 1.5), # Z offset tweaks are expected depending on curvature and OLED mount choice. - 'tbiw_oled_rotation_offset': (0, 0, 0), - - ########################################### - ## Trackball JS / ORBYL Thumb Cluster ## - ########################################## - 'other_thumb': 'DEFAULT', # cluster used for second thumb except if ball_side == 'both' - 'tbjs_key_diameter': 70, - # Offsets are per key and are applied before rotating into place around the ball - # X and Y act like Tangential and Radial around the ball - 'tbjs_translation_offset': (0, 0, 10), # applied to the whole assy - 'tbjs_rotation_offset': (0, 0, 0), # applied to the whole assy - 'tbjs_key_translation_offsets': [ - (0.0, 0.0, -3.0-5), - (0.0, 0.0, -3.0-5), - (0.0, 0.0, -3.0-5), - (0.0, 0.0, -3.0-5), - ], - 'tbjs_key_rotation_offsets': [ - (0.0, 0.0, 0.0), - (0.0, 0.0, 0.0), - (0.0, 0.0, 0.0), - (0.0, 0.0, 0.0), - ], - - ################################### - ## Trackball CJ Thumb Cluster ## - ################################### - 'tbcj_inner_diameter': 42, - 'tbcj_thickness': 2, - 'tbcj_outer_diameter': 53, - - - ################################### - ## Trackball General ## - ################################### - # EXPERIMENTAL - 'trackball_modular': False, # May add removable trackball in subsequent releases, no current use. - # END EXPERIMENTAL - - 'trackball_Usize': 1.5, # size for inner key near trackball - 'ball_side': 'right', #'left', 'right', or 'both' - 'ball_diameter': 34.0, - 'ball_wall_thickness': 3, # should not be changed unless the import models are changed. - 'ball_gap': 1.0, - 'trackball_hole_diameter': 36.5, - 'trackball_hole_height': 40, - 'trackball_plate_thickness': 2, - 'trackball_plate_width': 2, - # Removed trackball_rotation, ball_z_offset. and trackball_sensor_rotation and added more flexibility. - 'tb_socket_translation_offset': (0, 0, 2.0), # applied to the socket and sensor, large values will cause web/wall issues. - 'tb_socket_rotation_offset': (0, 0, 0), # applied to the socket and sensor, large values will cause web/wall issues. - 'tb_sensor_translation_offset': (0, 0, 0), #deviation from socket offsets, for fixing generated geometry issues - 'tb_sensor_rotation_offset': (0, 0, 0), #deviation from socket offsets, for changing the sensor roll orientation - - ############################## - # EXPERIMENTAL PARAMETERS - ############################## - 'pinky_1_5U': False, # LEAVE AS FALSE, CURRENTLY BROKEN - 'first_1_5U_row': 0, - 'last_1_5U_row': 5, - ############################## - - - 'extra_width': 2.5, # extra space between the base of keys# original= 2 - 'extra_height': 1.0, # original= 0.5 - - 'wall_z_offset': 15, # length of the first downward_sloping part of the wall - 'wall_x_offset': 5, # offset in the x and/or y direction for the first downward_sloping part of the wall (negative) - 'wall_y_offset': 6, # offset in the x and/or y direction for the first downward_sloping part of the wall (negative) - 'left_wall_x_offset': 12, # specific values for the left side due to the minimal wall. - 'left_wall_z_offset': 3, # specific values for the left side due to the minimal wall. - 'left_wall_lower_y_offset': 0, # specific values for the lower left corner. - 'left_wall_lower_z_offset': 0, - 'wall_thickness': 4.5, # wall thickness parameter used on upper/mid stage of the wall - 'wall_base_y_thickness': 4.5, # wall thickness at the lower stage - 'wall_base_x_thickness': 4.5, # wall thickness at the lower stage - - 'wall_base_back_thickness': 4.5, # wall thickness at the lower stage in the specifically in back for interface. - - ## Settings for column_style == :fixed - ## The defaults roughly match Maltron settings - ## http://patentimages.storage.googleapis.com/EP0219944A2/imgf0002.png - ## fixed_z overrides the z portion of the column ofsets above. - ## NOTE: THIS DOESN'T WORK QUITE LIKE I'D HOPED. - 'fixed_angles': [d2r * 10, d2r * 10, 0, 0, 0, d2r * -15, d2r * -15], - 'fixed_x': [-41.5, -22.5, 0, 20.3, 41.4, 65.5, 89.6], # relative to the middle finger - 'fixed_z': [12.1, 8.3, 0, 5, 10.7, 14.5, 17.5], - 'fixed_tenting': d2r * 0, - - ################# - ## Switch Hole ## - ################# - - # plate options are - # 'HOLE' = a square hole. Also useful for applying custom plate files. - # 'NUB' = original side nubs. - # 'UNDERCUT' = snap fit undercut. May require CLIP_THICKNESS and possibly CLIP_UNDERCUT tweaking - # and/or filing to get proper snap. - # 'NOTCH' = snap fit undercut only near switch clip. May require CLIP_THICKNESS and possibly CLIP_UNDERCUT - # tweaking and/or filing to get proper snap. - # 'HS_NUB' = hot swap underside with nubs. - # 'HS_UNDERCUT' = hot swap underside with undercut. Does not generate properly. Hot swap step needs to be modified. - # 'HS_NOTCH' = hot swap underside with notch. Does not generate properly. Hot swap step needs to be modified. - # 'plate_style': 'NUB', - 'plate_style': 'NOTCH', - - 'hole_keyswitch_height': 14.0, - 'hole_keyswitch_width': 14.0, - - 'nub_keyswitch_height': 14.4, - 'nub_keyswitch_width': 14.4, - - 'undercut_keyswitch_height': 14.0, - 'undercut_keyswitch_width': 14.0, - 'notch_width': 5.0, # If using notch, it is identical to undecut, but only locally by the switch clip - - 'sa_profile_key_height': 12.7, - 'sa_length': 18.5, - 'sa_double_length': 37.5, - 'plate_thickness': 4+1.1, - - 'plate_rim': 1.5 + 0.5, - # Undercut style dimensions - 'clip_thickness': 1.4, - 'clip_undercut': 1.0, - 'undercut_transition': .2, # NOT FUNCTIONAL WITH OPENSCAD, ONLY WORKS WITH CADQUERY - - # Custom plate step file - 'plate_file': None, - 'plate_offset': 0.0, - - ########################## - ## OLED Mount Location - ########################## - # Initial pass will be manual placement. Can be used to create other mounts as well. - # Mount type options: - # None or 'NONE' = No OLED mount - # 'UNDERCUT' = Simple rectangle with undercut for clip in item - # 'SLIDING' = Features to slide the OLED in place and use a pin or block to secure from underneath. - # 'CLIP' = Features to set the OLED in a frame a snap a bezel down to hold it in place. - - 'oled_mount_type': 'CLIP', - 'oled_center_row': 1.25, # if not None, this will override the oled_mount_location_xyz and oled_mount_rotation_xyz settings - 'oled_translation_offset': (0, 0, 4), # Z offset tweaks are expected depending on curvature and OLED mount choice. - 'oled_rotation_offset': (0, 0, 0), - - 'oled_configurations': { - 'UNDERCUT':{ - # Common parameters - 'oled_mount_width': 15.0, - 'oled_mount_height': 35.0, - 'oled_mount_rim': 3.0, - 'oled_mount_depth': 6.0, - 'oled_mount_cut_depth': 20.0, - 'oled_mount_location_xyz': (-80.0, 20.0, 45.0), # will be overwritten if oled_center_row is not None - 'oled_mount_rotation_xyz': (13.0, 0.0, -6.0), # will be overwritten if oled_center_row is not None - 'oled_left_wall_x_offset_override': 28.0, - 'oled_left_wall_z_offset_override': 0.0, - 'oled_left_wall_lower_y_offset': 12.0, - 'oled_left_wall_lower_z_offset': 5.0, - - # 'UNDERCUT' Parameters - 'oled_mount_undercut': 1.0, - 'oled_mount_undercut_thickness': 2.0, - }, - 'SLIDING': { - # Common parameters - 'oled_mount_width': 12.5, # width of OLED, plus clearance - 'oled_mount_height': 25.0, # length of screen - 'oled_mount_rim': 2.5, - 'oled_mount_depth': 8.0, - 'oled_mount_cut_depth': 20.0, - 'oled_mount_location_xyz': (-78.0, 10.0, 41.0), # will be overwritten if oled_center_row is not None - 'oled_mount_rotation_xyz': (6.0, 0.0, -3.0), # will be overwritten if oled_center_row is not None - 'oled_left_wall_x_offset_override': 24.0, - 'oled_left_wall_z_offset_override': 0.0, - 'oled_left_wall_lower_y_offset': 12.0, - 'oled_left_wall_lower_z_offset': 5.0, - - # 'SLIDING' Parameters - 'oled_thickness': 4.2, # thickness of OLED, plus clearance. Must include components - 'oled_edge_overlap_end': 6.5, # length from end of viewable screen to end of PCB - 'oled_edge_overlap_connector': 5.5, # length from end of viewable screen to end of PCB on connection side. - 'oled_edge_overlap_thickness': 2.5, # thickness of material over edge of PCB - 'oled_edge_overlap_clearance': 2.5, # Clearance to insert PCB before laying down and sliding. - 'oled_edge_chamfer': 2.0, - }, - 'CLIP': { - # Common parameters - 'oled_mount_width': 12.5, # whole OLED width - 'oled_mount_height': 39.0, # whole OLED length - 'oled_mount_rim': 2.0, - 'oled_mount_depth': 7.0, - 'oled_mount_cut_depth': 20.0, - 'oled_mount_location_xyz': (-78.0, 20.0, 42.0), # will be overwritten if oled_center_row is not None - 'oled_mount_rotation_xyz': (12.0, 0.0, -6.0), # will be overwritten if oled_center_row is not None - 'oled_left_wall_x_offset_override': 24.0, - 'oled_left_wall_z_offset_override': 0.0, - 'oled_left_wall_lower_y_offset': 12.0, - 'oled_left_wall_lower_z_offset': 5.0, - - # 'CLIP' Parameters - 'oled_thickness': 4.2, # thickness of OLED, plus clearance. Must include components - 'oled_mount_bezel_thickness': 3.5, # z thickness of clip bezel - 'oled_mount_bezel_chamfer': 2.0, # depth of the 45 degree chamfer - 'oled_mount_connector_hole': 6.0, - 'oled_screen_start_from_conn_end': 6.5, - 'oled_screen_length': 24.5, - 'oled_screen_width': 10.5, - 'oled_clip_thickness': 1.5, - 'oled_clip_width': 6.0, - 'oled_clip_overhang': 1.0, - 'oled_clip_extension': 5.0, - 'oled_clip_width_clearance': 0.5, - 'oled_clip_undercut': 0.5, - 'oled_clip_undercut_thickness': 2.5, - 'oled_clip_y_gap': .2, - 'oled_clip_z_gap': .2, - } - }, - 'web_thickness': 4.0, - 'post_size': 0.1, - # post_adj': post_size / 2 - 'post_adj': 0, - 'screws_offset': 'INSIDE', #'OUTSIDE', 'INSIDE', 'ORIGINAL' - - 'screw_insert_height': 3.8, - 'screw_insert_bottom_radius': 5.31 / 2, - 'screw_insert_top_radius': 5.1 / 2, - - # Does anyone even use these? I think they just get in the way. - 'wire_post_height': 7, - 'wire_post_overhang': 3.5, - 'wire_post_diameter': 2.6, - - - - - ################################### - ## Controller Mount / Connectors ## - ################################### - # connector options are - # 'RJ9_USB_WALL' = Standard internal plate with RJ9 opening and square cutout for connection. - # 'USB_WALL' = Standard internal plate with a square cutout for connection, no RJ9. - # 'RJ9_USB_TEENSY' = Teensy holder - # 'USB_TEENSY' = Teensy holder, no RJ9 - # 'EXTERNAL' = square cutout for a holder such as the one from lolligagger. - # 'NONE' = No openings in the back. - 'controller_mount_type': 'EXTERNAL', - - 'external_holder_height': 12.5, - 'external_holder_width': 28.75, - 'external_holder_xoffset': -5.0, - 'external_holder_yoffset': -4.5, #Tweak this value to get the right undercut for the tray engagement. - - # Offset is from the top inner corner of the top inner key. - - ################################### - ## Bottom Plate Dimensions - ################################### - # COMMON DIMENSION - 'screw_hole_diameter': 2, - # USED FOR CADQUERY ONLY - 'base_thickness': 3.0, # thickness in the middle of the plate - 'base_offset': 3.0, # Both start flat/flush on the bottom. This offsets the base up (if positive) - 'base_rim_thickness': 5.0, # thickness on the outer frame with screws - 'screw_cbore_diameter': 4.0, - 'screw_cbore_depth': 2.0, - - # Offset is from the top inner corner of the top inner key. - - ################################### - ## HOLES ON PLATE FOR PCB MOUNT - ################################### - 'plate_holes': False, - 'plate_holes_xy_offset': (0.0, 0.0), - 'plate_holes_width': 14.3, - 'plate_holes_height': 14.3, - 'plate_holes_diameter': 1.7, - 'plate_holes_depth': 20.0, - - ################################### - ## SHOW PCB FOR FIT CHECK - ################################### - 'pcb_width': 18.0, - 'pcb_height': 18.0, - 'pcb_thickness': 1.5, - 'pcb_hole_diameter': 2, - 'pcb_hole_pattern_width': 14.3, - 'pcb_hole_pattern_height': 14.3, - - ################################### - ## COLUMN OFFSETS - #################################### - - 'column_offsets': [ - [0, 0, 0], - [0, 0, 0], - [0, 2.82, -4.5], - [0, 0, 0], - [0, -6, 5],# REDUCED STAGGER - [0, -6, 5],# REDUCED STAGGER - [0, -6, 5],# NOT USED IN MOST FORMATS (7th column) - ], - -} - - #################################### - ## END CONFIGURATION SECTION - #################################### - -def save_config(): - # Check to see if the user has specified an alternate config - opts, args = getopt.getopt(sys.argv[1:], "", ["config=", "update="]) - for opt, arg in opts: - if opt in ('--update'): - with open(os.path.join(r"..", "configs", arg + '.json'), mode='r') as fid: - data = json.load(fid) - shape_config.update(data) - - for opt, arg in opts: - if opt in ('--config'): - # If a config file was specified, set the config_name and save_dir - shape_config['save_dir'] = arg - shape_config['config_name'] = arg - - # Write the config to ./configs/.json - with open(os.path.join(r"..", "configs", shape_config['config_name'] + '.json'), mode='w') as fid: +from . import default_configuration + +def save_config(opts): + shape_config = default_configuration.shape_config + shape_config['save_dir'] = opts['config']['relative_path'] + shape_config['config_name'] = opts['config']['name'] + + if opts['update']: + with open(opts['config']['absolute_path'], mode='r') as fid: + data = json.load(fid) + shape_config.update(data) + elif os.path.exists(opts['config']['absolute_path']): + print("A config already exists at the specified location. Use '--update' to continue") + sys.exit(1) + + if not os.path.exists(os.path.dirname(opts['config']['absolute_path'])): + os.makedirs(os.path.dirname(opts['config']['absolute_path'])) + + with open(opts['config']['absolute_path'], mode='w') as fid: json.dump(shape_config, fid, indent=4) - - -if __name__ == '__main__': - save_config() \ No newline at end of file From 690f3bff2e5d0779e139e1e42e899aa3da4bcc5c Mon Sep 17 00:00:00 2001 From: Edward Date: Mon, 23 Aug 2021 12:43:36 -0400 Subject: [PATCH 02/10] modularized model_builder.py --- src/model_builder.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/model_builder.py b/src/model_builder.py index 7cca38790..da5850b32 100644 --- a/src/model_builder.py +++ b/src/model_builder.py @@ -1,10 +1,11 @@ import os import copy import importlib -from generate_configuration import * +import json +from . import default_configuration -base = shape_config +base = default_configuration.shape_config config_options = [ { @@ -99,10 +100,17 @@ def build_release(base, configurations, engines=('solid', 'cadquery')): importlib.reload(dactyl_manuform) dactyl_manuform.run() -if __name__ == '__main__': + + +def run(): configurations = create_config(config_options) ENGINES = ['solid', 'cadquery'] # ENGINES = ['solid'] build_release(base, configurations, ENGINES) + + + +if __name__ == '__main__': + run() From b8da9663bfe85be36d53fc657d6801f1e2354549 Mon Sep 17 00:00:00 2001 From: Edward Date: Mon, 23 Aug 2021 12:44:13 -0400 Subject: [PATCH 03/10] WIP: modularizing dactyl_manuform.py --- src/dactyl_manuform.py | 283 ++++++++++++++++++----------------------- 1 file changed, 127 insertions(+), 156 deletions(-) diff --git a/src/dactyl_manuform.py b/src/dactyl_manuform.py index a04a2918a..d73856012 100644 --- a/src/dactyl_manuform.py +++ b/src/dactyl_manuform.py @@ -1,175 +1,175 @@ import numpy as np from numpy import pi +import math import os.path as path import getopt, sys import json import os - +from . import default_configuration from scipy.spatial import ConvexHull as sphull + +debug_exports = False +debug_trace = False +shape_config = default_configuration.shape_config +save_path = path.join(r"..", "things") +parts_path = path.join(r"..", "src", "parts") +column_style = "standard" + +def debugprint(info): + if debug_trace: + print(info) + def deg2rad(degrees: float) -> float: return degrees * pi / 180 - def rad2deg(rad: float) -> float: return rad * 180 / pi +def setup(opts): + global shape_config + global save_path + global parts_path + global column_style -############################################### -# EXTREMELY UGLY BUT FUNCTIONAL BOOTSTRAP -############################################### - -## IMPORT DEFAULT CONFIG IN CASE NEW PARAMETERS EXIST -import generate_configuration as cfg -for item in cfg.shape_config: - locals()[item] = cfg.shape_config[item] - -if len(sys.argv) <= 1: - print("NO CONFIGURATION SPECIFIED, USING run_config.json") - with open(os.path.join(r".", 'run_config.json'), mode='r') as fid: + with open(opts['config']['absolute_path'], mode='r') as fid: data = json.load(fid) + for item in data: + shape_config[item] = data[item] -else: - ## CHECK FOR CONFIG FILE AND WRITE TO ANY VARIABLES IN FILE. - opts, args = getopt.getopt(sys.argv[1:], "", ["config="]) - for opt, arg in opts: - if opt in ('--config'): - with open(os.path.join(r"..", "configs", arg + '.json'), mode='r') as fid: - data = json.load(fid) -for item in data: - locals()[item] = data[item] + # Really rough setup. Check for ENGINE, set it not present from configuration. + try: + print('Found Current Engine in Config = {}'.format(shape_config['ENGINE'])) + except Exception: + print('Engine Not Found in Config') + shape_config['ENGINE'] = 'solid' + print('Setting Current Engine = {}'.format(shape_config['ENGINE'])) + if shape_config['save_dir'] not in ['', None, '.']: + save_path = path.join(r"..", "things", shape_config['save_dir']) + parts_path = path.join(r"..", r"..", "src", "parts") -# Really rough setup. Check for ENGINE, set it not present from configuration. -try: - print('Found Current Engine in Config = {}'.format(ENGINE)) -except Exception: - print('Engine Not Found in Config') - ENGINE = 'solid' - # ENGINE = 'cadquery' - print('Setting Current Engine = {}'.format(ENGINE)) - -if save_dir in ['', None, '.']: - save_path = path.join(r"..", "things") - parts_path = path.join(r"..", "src", "parts") -else: - save_path = path.join(r"..", "things", save_dir) - parts_path = path.join(r"..", r"..", "src", "parts") - -############################################### -# END EXTREMELY UGLY BOOTSTRAP -############################################### - -#################################################### -# HELPER FUNCTIONS TO MERGE CADQUERY AND OPENSCAD -#################################################### - -if ENGINE == 'cadquery': - from helpers_cadquery import * -else: - from helpers_solid import * - -#################################################### -# END HELPER FUNCTIONS -#################################################### + if shape_config['ENGINE'] == 'cadquery': + from . import helpers_cadquery as helpers + else: + from . import helpers_solid as helpers + column_style = shape_config['column_style'] -debug_exports = False -debug_trace = False + if shape_config['oled_mount_type'] is not None and shape_config['oled_mount_type'] != "NONE": + for item in shape_config['oled_configurations'][shape_config['oled_mount_type']]: + shape_config[item] = shape_config['oled_configurations'][shape_config['oled_mount_type']][item] -def debugprint(info): - if debug_trace: - print(info) + if shape_config['nrows'] > 5: + shape_config['column_style'] = shape_config['column_style_gt5'] + shape_config['centerrow'] = shape_config['nrows'] - shape_config['centerrow_offset'] -if oled_mount_type is not None and oled_mount_type != "NONE": - for item in oled_configurations[oled_mount_type]: - locals()[item] = oled_configurations[oled_mount_type][item] + shape_config['lastrow'] = shape_config['nrows'] - 1 + shape_config['cornerrow'] = shape_config['lastrow'] - 1 + shape_config['lastcol'] = shape_config['ncols'] - 1 -if nrows > 5: - column_style = column_style_gt5 -centerrow = nrows - centerrow_offset + # Derived values + if shape_config['plate_style'] in ['NUB', 'HS_NUB']: + shape_config['keyswitch_height'] = shape_config['nub_keyswitch_height'] + shape_config['keyswitch_width'] = shape_config['nub_keyswitch_width'] + elif shape_config['plate_style'] in ['UNDERCUT', 'HS_UNDERCUT', 'NOTCH', 'HS_NOTCH']: + shape_config['keyswitch_height'] = shape_config['undercut_keyswitch_height'] + shape_config['keyswitch_width'] = shape_config['undercut_keyswitch_width'] + else: + shape_config['keyswitch_height'] = shape_config['hole_keyswitch_height'] + shape_config['keyswitch_width'] = shape_config['hole_keyswitch_width'] -lastrow = nrows - 1 -cornerrow = lastrow - 1 -lastcol = ncols - 1 + if 'HS_' in shape_config['plate_style']: + shape_config['symmetry'] = "asymmetric" + shape_config['plate_file'] = path.join(parts_path, r"hot_swap_plate") + shape_config['plate_offset'] = 0.0 + if (shape_config['trackball_in_wall'] or ('TRACKBALL' in shape_config['thumb_style'])) and not shape_config['ball_side'] == 'both': + shape_config['symmetry'] = "asymmetric" -# Derived values -if plate_style in ['NUB', 'HS_NUB']: - keyswitch_height = nub_keyswitch_height - keyswitch_width = nub_keyswitch_width -elif plate_style in ['UNDERCUT', 'HS_UNDERCUT', 'NOTCH', 'HS_NOTCH']: - keyswitch_height = undercut_keyswitch_height - keyswitch_width = undercut_keyswitch_width -else: - keyswitch_height = hole_keyswitch_height - keyswitch_width = hole_keyswitch_width + shape_config['mount_width'] = shape_config['keyswitch_width'] + 2 * shape_config['plate_rim'] + shape_config['mount_height'] = shape_config['keyswitch_height'] + 2 * shape_config['plate_rim'] + shape_config['mount_thickness'] = shape_config['plate_thickness'] -if 'HS_' in plate_style: - symmetry = "asymmetric" - plate_file = path.join(parts_path, r"hot_swap_plate") - plate_offset = 0.0 + if shape_config['default_1U_cluster'] and shape_config['thumb_style']=='DEFAULT': + shape_config['double_plate_height'] = (.7*shape_config['sa_double_length'] - shape_config['mount_height']) / 3 + elif shape_config['thumb_style']=='DEFAULT': + shape_config['double_plate_height'] = (.95*shape_config['sa_double_length'] - shape_config['mount_height']) / 3 + else: + shape_config['double_plate_height'] = (shape_config['sa_double_length'] - shape_config['mount_height']) / 3 -if (trackball_in_wall or ('TRACKBALL' in thumb_style)) and not ball_side == 'both': - symmetry = "asymmetric" -mount_width = keyswitch_width + 2 * plate_rim -mount_height = keyswitch_height + 2 * plate_rim -mount_thickness = plate_thickness -if default_1U_cluster and thumb_style=='DEFAULT': - double_plate_height = (.7*sa_double_length - mount_height) / 3 -elif thumb_style=='DEFAULT': - double_plate_height = (.95*sa_double_length - mount_height) / 3 -else: - double_plate_height = (sa_double_length - mount_height) / 3 + if shape_config['oled_mount_type'] is not None and shape_config['oled_mount_type'] != "NONE": + shape_config['left_wall_x_offset'] = shape_config['oled_left_wall_x_offset_override'] + shape_config['left_wall_z_offset'] = shape_config['oled_left_wall_z_offset_override'] + shape_config['left_wall_lower_y_offset'] = shape_config['oled_left_wall_lower_y_offset'] + shape_config['left_wall_lower_z_offset'] = shape_config['oled_left_wall_lower_z_offset'] -if oled_mount_type is not None and oled_mount_type != "NONE": - left_wall_x_offset = oled_left_wall_x_offset_override - left_wall_z_offset = oled_left_wall_z_offset_override - left_wall_lower_y_offset = oled_left_wall_lower_y_offset - left_wall_lower_z_offset = oled_left_wall_lower_z_offset + shape_config['cap_top_height'] = shape_config['plate_thickness'] + shape_config['sa_profile_key_height'] + shape_config['row_radius'] = ((shape_config['mount_height'] + shape_config['extra_height']) / 2) / (np.sin(shape_config['alpha'] / 2)) + shape_config['cap_top_height'] + shape_config['column_radius'] = ( + ((shape_config['mount_width'] + shape_config['extra_width']) / 2) / (np.sin(shape_config['beta'] / 2)) + ) + shape_config['cap_top_height'] + shape_config['column_x_delta'] = -1 - shape_config['column_radius'] * np.sin(shape_config['beta']) + shape_config['column_base_angle'] = shape_config['beta'] * (shape_config['centercol'] - 2) + shape_config['teensy_width'] = 20 + shape_config['teensy_height'] = 12 + shape_config['teensy_length'] = 33 + shape_config['teensy2_length'] = 53 + shape_config['teensy_pcb_thickness'] = 2 + shape_config['teensy_offset_height'] = 5 + shape_config['teensy_holder_top_length'] = 18 + shape_config['teensy_holder_width'] = 7 + shape_config['teensy_pcb_thickness'] + shape_config['teensy_holder_height'] = 6 + shape_config['teensy_width'] -cap_top_height = plate_thickness + sa_profile_key_height -row_radius = ((mount_height + extra_height) / 2) / (np.sin(alpha / 2)) + cap_top_height -column_radius = ( - ((mount_width + extra_width) / 2) / (np.sin(beta / 2)) - ) + cap_top_height -column_x_delta = -1 - column_radius * np.sin(beta) -column_base_angle = beta * (centercol - 2) + shape_config['rj9_start'] = list( + np.array([0, -3, 0]) + + np.array( + key_position( + list(np.array(wall_locate3(0, 1)) + np.array([0, (shape_config['mount_height'] / 2), 0])), + 0, + 0, + ) + ) + ) + rj9_position = (shape_config['rj9_start'][0], shape_config['rj9_start'][1], 11) + shape_config['usb_holder_position'] = key_position( + list(np.array(wall_locate2(0, 1)) + np.array([0, (shape_config['mount_height'] / 2), 0])), 1, 0 + ) + shape_config['usb_holder_size'] = [6.5, 10.0, 13.6] + shape_config['usb_holder_thickness'] = 4 -teensy_width = 20 -teensy_height = 12 -teensy_length = 33 -teensy2_length = 53 -teensy_pcb_thickness = 2 -teensy_offset_height = 5 -teensy_holder_top_length = 18 -teensy_holder_width = 7 + teensy_pcb_thickness -teensy_holder_height = 6 + teensy_width + external_start = list( + # np.array([0, -3, 0]) + np.array([shape_config['external_holder_width'] / 2, 0, 0]) + + np.array( + key_position( + list(np.array(wall_locate3(0, 1)) + np.array([0, (shape_config['mount_height'] / 2), 0])), + 0, + 0, + ) + ) + ) + if not path.isdir(save_path): + os.mkdir(save_path) -# save_path = path.join("..", "things", save_dir) -if not path.isdir(save_path): - os.mkdir(save_path) def column_offset(column: int) -> list: return column_offsets[column] -# column_style='fixed' - - def single_plate(cylinder_segments=100, side="right"): if plate_style in ['NUB', 'HS_NUB']: @@ -2120,7 +2120,6 @@ def tbcj_thumb_layout(shape): # # return translate(shape, (points_x[i] * radius / 2, points_y[i] * radius / 2, 0)) -import math def oct_corner(i, diameter, shape): radius = diameter / 2 i = (i+1)%8 @@ -3134,20 +3133,6 @@ def case_walls(side='right'): ) -rj9_start = list( - np.array([0, -3, 0]) - + np.array( - key_position( - list(np.array(wall_locate3(0, 1)) + np.array([0, (mount_height / 2), 0])), - 0, - 0, - ) - ) -) - -rj9_position = (rj9_start[0], rj9_start[1], 11) - - def rj9_cube(): debugprint('rj9_cube()') shape = box(14.78, 13, 22.38) @@ -3169,11 +3154,7 @@ def rj9_holder(): return shape -usb_holder_position = key_position( - list(np.array(wall_locate2(0, 1)) + np.array([0, (mount_height / 2), 0])), 1, 0 -) -usb_holder_size = [6.5, 10.0, 13.6] -usb_holder_thickness = 4 + def usb_holder(): @@ -3206,18 +3187,6 @@ def usb_holder_hole(): return shape -external_start = list( - # np.array([0, -3, 0]) - np.array([external_holder_width / 2, 0, 0]) - + np.array( - key_position( - list(np.array(wall_locate3(0, 1)) + np.array([0, (mount_height / 2), 0])), - 0, - 0, - ) - ) -) - def external_mount_hole(): print('external_mount_hole()') shape = box(external_holder_width, 20.0, external_holder_height+.1) @@ -4036,7 +4005,11 @@ def baseplate(wedge_angle=None, side='right'): return sl.projection(cut=True)(shape) -def run(): +def run(opts): + setup(opts) + print(save_path) + print(parts_path) + exit(0) mod_r = model_side(side="right") export_file(shape=mod_r, fname=path.join(save_path, config_name + r"_right")) @@ -4080,5 +4053,3 @@ def run(): # base = baseplate() # export_file(shape=base, fname=path.join(save_path, config_name + r"_plate")) -if __name__ == '__main__': - run() From 58de8e99ac9eb66a1105140ec763b3f47e57dd42 Mon Sep 17 00:00:00 2001 From: Edward Date: Mon, 23 Aug 2021 21:37:33 -0400 Subject: [PATCH 04/10] more readable output --- run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/run.sh b/run.sh index a5ca8a8a2..34d5d2ae4 100755 --- a/run.sh +++ b/run.sh @@ -53,6 +53,7 @@ while [ "$(docker inspect --format={{.State.Status}} dm-run)" != 'exited' ]; do echo -n "." sleep 1.5 done +echo "" # display the output of run.py docker logs dm-run From 458ccb645ff4d02be94a11ff8823240a31977dd0 Mon Sep 17 00:00:00 2001 From: Edward Date: Mon, 23 Aug 2021 21:38:09 -0400 Subject: [PATCH 05/10] lots of find/replace to continue modularization --- src/dactyl_manuform.py | 2783 ++++++++++++++++++++-------------------- 1 file changed, 1390 insertions(+), 1393 deletions(-) diff --git a/src/dactyl_manuform.py b/src/dactyl_manuform.py index d73856012..a4de8b857 100644 --- a/src/dactyl_manuform.py +++ b/src/dactyl_manuform.py @@ -7,12 +7,13 @@ import os from . import default_configuration from scipy.spatial import ConvexHull as sphull +import solid as sl debug_exports = False debug_trace = False shape_config = default_configuration.shape_config -save_path = path.join(r"..", "things") +save_path = path.join("things") parts_path = path.join(r"..", "src", "parts") column_style = "standard" @@ -26,6 +27,7 @@ def deg2rad(degrees: float) -> float: def rad2deg(rad: float) -> float: return rad * 180 / pi + def setup(opts): global shape_config global save_path @@ -47,9 +49,10 @@ def setup(opts): print('Setting Current Engine = {}'.format(shape_config['ENGINE'])) if shape_config['save_dir'] not in ['', None, '.']: - save_path = path.join(r"..", "things", shape_config['save_dir']) + save_path = path.join("things", shape_config['save_dir']) parts_path = path.join(r"..", r"..", "src", "parts") + global helpers if shape_config['ENGINE'] == 'cadquery': from . import helpers_cadquery as helpers else: @@ -141,7 +144,7 @@ def setup(opts): ) ) ) - rj9_position = (shape_config['rj9_start'][0], shape_config['rj9_start'][1], 11) + shape_config['rj9_position'] = (shape_config['rj9_start'][0], shape_config['rj9_start'][1], 11) shape_config['usb_holder_position'] = key_position( list(np.array(wall_locate2(0, 1)) + np.array([0, (shape_config['mount_height'] / 2), 0])), 1, 0 @@ -150,7 +153,7 @@ def setup(opts): shape_config['usb_holder_thickness'] = 4 - external_start = list( + shape_config['external_start'] = list( # np.array([0, -3, 0]) np.array([shape_config['external_holder_width'] / 2, 0, 0]) + np.array( @@ -166,121 +169,119 @@ def setup(opts): os.mkdir(save_path) - def column_offset(column: int) -> list: - return column_offsets[column] + return shape_config['column_offsets'][column] def single_plate(cylinder_segments=100, side="right"): + if shape_config['plate_style'] in ['NUB', 'HS_NUB']: + tb_border = (shape_config['mount_height']-shape_config['keyswitch_height'])/2 + top_wall = helpers.box(shape_config['mount_width'], tb_border, shape_config['plate_thickness']) + top_wall = helpers.translate(top_wall, (0, (tb_border / 2) + (shape_config['keyswitch_height'] / 2), shape_config['plate_thickness'] / 2)) - if plate_style in ['NUB', 'HS_NUB']: - tb_border = (mount_height-keyswitch_height)/2 - top_wall = box(mount_width, tb_border, plate_thickness) - top_wall = translate(top_wall, (0, (tb_border / 2) + (keyswitch_height / 2), plate_thickness / 2)) - - lr_border = (mount_width - keyswitch_width) / 2 - left_wall = box(lr_border, mount_height, plate_thickness) - left_wall = translate(left_wall, ((lr_border / 2) + (keyswitch_width / 2), 0, plate_thickness / 2)) + lr_border = (shape_config['mount_width'] - shape_config['keyswitch_width']) / 2 + left_wall = helpers.box(lr_border, shape_config['mount_height'], shape_config['plate_thickness']) + left_wall = helpers.translate(left_wall, ((lr_border / 2) + (shape_config['keyswitch_width'] / 2), 0, shape_config['plate_thickness'] / 2)) - side_nub = cylinder(radius=1, height=2.75) - side_nub = rotate(side_nub, (90, 0, 0)) - side_nub = translate(side_nub, (keyswitch_width / 2, 0, 1)) + side_nub = helpers.cylinder(radius=1, height=2.75) + side_nub = helpers.rotate(side_nub, (90, 0, 0)) + side_nub = helpers.translate(side_nub, (shape_config['keyswitch_width'] / 2, 0, 1)) - nub_cube = box(1.5, 2.75, plate_thickness) - nub_cube = translate(nub_cube, ((1.5 / 2) + (keyswitch_width / 2), 0, plate_thickness / 2)) + nub_cube = helpers.box(1.5, 2.75, shape_config['plate_thickness']) + nub_cube = helpers.translate(nub_cube, ((1.5 / 2) + (shape_config['keyswitch_width'] / 2), 0, shape_config['plate_thickness'] / 2)) - side_nub2 = tess_hull(shapes=(side_nub, nub_cube)) - side_nub2 = union([side_nub2, side_nub, nub_cube]) + side_nub2 = helpers.tess_hull(shapes=(side_nub, nub_cube)) + side_nub2 = helpers.union([side_nub2, side_nub, nub_cube]) - plate_half1 = union([top_wall, left_wall, side_nub2]) + plate_half1 = helpers.union([top_wall, left_wall, side_nub2]) plate_half2 = plate_half1 - plate_half2 = mirror(plate_half2, 'XZ') - plate_half2 = mirror(plate_half2, 'YZ') + plate_half2 = helpers.mirror(plate_half2, 'XZ') + plate_half2 = helpers.mirror(plate_half2, 'YZ') - plate = union([plate_half1, plate_half2]) + plate = helpers.union([plate_half1, plate_half2]) else: # 'HOLE' or default, square cutout for non-nub designs. - plate = box(mount_width, mount_height, mount_thickness) - plate = translate(plate, (0.0, 0.0, mount_thickness / 2.0)) + plate = helpers.box(shape_config['mount_width'], shape_config['mount_height'], shape_config['mount_thickness']) + plate = helpers.translate(plate, (0.0, 0.0, shape_config['mount_thickness'] / 2.0)) - shape_cut = box(keyswitch_width, keyswitch_height, mount_thickness * 2 +.02) - shape_cut = translate(shape_cut, (0.0, 0.0, mount_thickness-.01)) + shape_cut = helpers.box(shape_config['keyswitch_width'], shape_config['keyswitch_height'], shape_config['mount_thickness'] * 2 +.02) + shape_cut = helpers.translate(shape_cut, (0.0, 0.0, shape_config['mount_thickness']-.01)) - plate = difference(plate, [shape_cut]) + plate = helpers.difference(plate, [shape_cut]) - if plate_style in ['UNDERCUT', 'HS_UNDERCUT', 'NOTCH', 'HS_NOTCH']: - if plate_style in ['UNDERCUT', 'HS_UNDERCUT']: - undercut = box( - keyswitch_width + 2 * clip_undercut, - keyswitch_height + 2 * clip_undercut, - mount_thickness + if shape_config['plate_style'] in ['UNDERCUT', 'HS_UNDERCUT', 'NOTCH', 'HS_NOTCH']: + if shape_config['plate_style'] in ['UNDERCUT', 'HS_UNDERCUT']: + undercut = helpers.box( + shape_config['keyswitch_width'] + 2 * shape_config['clip_undercut'], + shape_config['keyswitch_height'] + 2 * shape_config['clip_undercut'], + shape_config['mount_thickness'] ) - if plate_style in ['NOTCH', 'HS_NOTCH']: - undercut = box( - notch_width, - keyswitch_height + 2 * clip_undercut, - mount_thickness + if shape_config['plate_style'] in ['NOTCH', 'HS_NOTCH']: + undercut = helpers.box( + shape_config['notch_width'], + shape_config['keyswitch_height'] + 2 * shape_config['clip_undercut'], + shape_config['mount_thickness'] ) - undercut = union([undercut, - box( - keyswitch_width + 2 * clip_undercut, - notch_width, - mount_thickness + undercut = helpers.union([undercut, + helpers.box( + shape_config['keyswitch_width'] + 2 * shape_config['clip_undercut'], + shape_config['notch_width'], + shape_config['mount_thickness'] ) ]) - undercut = translate(undercut, (0.0, 0.0, -clip_thickness + mount_thickness / 2.0)) + undercut = helpers.translate(undercut, (0.0, 0.0, -shape_config['clip_thickness'] + shape_config['mount_thickness'] / 2.0)) - if ENGINE=='cadquery' and undercut_transition > 0: - undercut = undercut.faces("+Z").chamfer(undercut_transition, clip_undercut) + if shape_config['ENGINE']=='cadquery' and shape_config['undercut_transition'] > 0: + undercut = undercut.faces("+Z").chamfer(shape_config['undercut_transition'], shape_config['clip_undercut']) - plate = difference(plate, [undercut]) + plate = helpers.difference(plate, [undercut]) - if plate_file is not None: - socket = import_file(plate_file) - socket = translate(socket, [0, 0, plate_thickness + plate_offset]) - plate = union([plate, socket]) + if shape_config['plate_file'] is not None: + socket = helpers.import_file(shape_config['plate_file']) + socket = helpers.translate(socket, [0, 0, shape_config['plate_thickness'] + shape_config['plate_offset']]) + plate = helpers.union([plate, socket]) - if plate_holes: - half_width = plate_holes_width/2. - half_height = plate_holes_height/2. - x_off = plate_holes_xy_offset[0] - y_off = plate_holes_xy_offset[1] + if shape_config['plate_holes']: + half_width = shape_config['plate_holes_width']/2. + half_height = shape_config['plate_holes_height']/2. + x_off = shape_config['plate_holes_xy_offset'][0] + y_off = shape_config['plate_holes_xy_offset'][1] holes = [ - translate( - cylinder(radius=plate_holes_diameter/2, height=plate_holes_depth+.01), - (x_off+half_width, y_off+half_height, plate_holes_depth/2-.01) + helpers.translate( + helpers.cylinder(radius=shape_config['plate_holes_diameter']/2, height=shape_config['plate_holes_depth']+.01), + (x_off+half_width, y_off+half_height, shape_config['plate_holes_depth']/2-.01) ), - translate( - cylinder(radius=plate_holes_diameter / 2, height=plate_holes_depth+.01), - (x_off-half_width, y_off+half_height, plate_holes_depth/2-.01) + helpers.translate( + helpers.cylinder(radius=shape_config['plate_holes_diameter'] / 2, height=shape_config['plate_holes_depth']+.01), + (x_off-half_width, y_off+half_height, shape_config['plate_holes_depth']/2-.01) ), - translate( - cylinder(radius=plate_holes_diameter / 2, height=plate_holes_depth+.01), - (x_off-half_width, y_off-half_height, plate_holes_depth/2-.01) + helpers.translate( + helpers.cylinder(radius=shape_config['plate_holes_diameter'] / 2, height=shape_config['plate_holes_depth']+.01), + (x_off-half_width, y_off-half_height, shape_config['plate_holes_depth']/2-.01) ), - translate( - cylinder(radius=plate_holes_diameter / 2, height=plate_holes_depth+.01), - (x_off+half_width, y_off-half_height, plate_holes_depth/2-.01) + helpers.translate( + helpers.cylinder(radius=shape_config['plate_holes_diameter'] / 2, height=shape_config['plate_holes_depth']+.01), + (x_off+half_width, y_off-half_height, shape_config['plate_holes_depth']/2-.01) ), ] - plate = difference(plate, holes) + plate = helpers.difference(plate, holes) if side == "left": - plate = mirror(plate, 'YZ') + plate = helpers.mirror(plate, 'YZ') return plate def trackball_cutout(segments=100, side="right"): - shape = cylinder(trackball_hole_diameter / 2, trackball_hole_height) + shape = helpers.cylinder(shape_config['trackball_hole_diameter'] / 2, shape_config['trackball_hole_height']) return shape def trackball_socket(segments=100, side="right"): - # shape = sphere(ball_diameter / 2) - # cyl = cylinder(ball_diameter / 2 + 4, 20) - # cyl = translate(cyl, (0, 0, -8)) - # shape = union([shape, cyl]) + # shape = helpers.sphere(shape_config['ball_diameter'] / 2) + # cyl = helpers.cylinder(shape_config['ball_diameter'] / 2 + 4, 20) + # cyl = helpers.translate(cyl, (0, 0, -8)) + # shape = helpers.union([shape, cyl]) tb_file = path.join(parts_path, r"trackball_socket_body_34mm") tbcut_file = path.join(parts_path, r"trackball_socket_cutter_34mm") @@ -288,21 +289,21 @@ def trackball_socket(segments=100, side="right"): senscut_file = path.join(parts_path, r"trackball_sensor_cutter") - # shape = import_file(tb_file) - # # shape = difference(shape, [import_file(senscut_file)]) - # # shape = union([shape, import_file(sens_file)]) - # cutter = import_file(tbcut_file) + # shape = helpers.import_file(tb_file) + # # shape = helpers.difference(shape, [helpers.import_file(senscut_file)]) + # # shape = helpers.union([shape, helpers.import_file(sens_file)]) + # cutter = helpers.import_file(tbcut_file) - shape = import_file(tb_file) - sensor = import_file(sens_file) - cutter = import_file(tbcut_file) - cutter = union([cutter, import_file(senscut_file)]) + shape = helpers.import_file(tb_file) + sensor = helpers.import_file(sens_file) + cutter = helpers.import_file(tbcut_file) + cutter = helpers.union([cutter, helpers.import_file(senscut_file)]) # return shape, cutter return shape, cutter, sensor def trackball_ball(segments=100, side="right"): - shape = sphere(ball_diameter / 2) + shape = helpers.sphere(shape_config['ball_diameter'] / 2) return shape ################ @@ -314,7 +315,7 @@ def trackball_ball(segments=100, side="right"): def sa_cap(Usize=1): # MODIFIED TO NOT HAVE THE ROTATION. NEEDS ROTATION DURING ASSEMBLY - # sa_length = 18.25 + # shape_config['sa_length'] = 18.25 if Usize == 1: bl2 = 18.5/2 @@ -324,52 +325,52 @@ def sa_cap(Usize=1): pw2 = 6 elif Usize == 2: - bl2 = sa_length - bw2 = sa_length / 2 + bl2 = shape_config['sa_length'] + bw2 = shape_config['sa_length'] / 2 m = 0 pl2 = 16 pw2 = 6 elif Usize == 1.5: - bl2 = sa_length / 2 + bl2 = shape_config['sa_length'] / 2 bw2 = 27.94 / 2 m = 0 pl2 = 6 pw2 = 11 - k1 = polyline([(bw2, bl2), (bw2, -bl2), (-bw2, -bl2), (-bw2, bl2), (bw2, bl2)]) - k1 = extrude_poly(outer_poly=k1, height=0.1) - k1 = translate(k1, (0, 0, 0.05)) - k2 = polyline([(pw2, pl2), (pw2, -pl2), (-pw2, -pl2), (-pw2, pl2), (pw2, pl2)]) - k2 = extrude_poly(outer_poly=k2, height=0.1) - k2 = translate(k2, (0, 0, 12.0)) + k1 = helpers.polyline([(bw2, bl2), (bw2, -bl2), (-bw2, -bl2), (-bw2, bl2), (bw2, bl2)]) + k1 = helpers.extrude_poly(outer_poly=k1, height=0.1) + k1 = helpers.translate(k1, (0, 0, 0.05)) + k2 = helpers.polyline([(pw2, pl2), (pw2, -pl2), (-pw2, -pl2), (-pw2, pl2), (pw2, pl2)]) + k2 = helpers.extrude_poly(outer_poly=k2, height=0.1) + k2 = helpers.translate(k2, (0, 0, 12.0)) if m > 0: - m1 = polyline([(m, m), (m, -m), (-m, -m), (-m, m), (m, m)]) - m1 = extrude_poly(outer_poly=m1, height=0.1) - m1 = translate(m1, (0, 0, 6.0)) - key_cap = hull_from_shapes((k1, k2, m1)) + m1 = helpers.polyline([(m, m), (m, -m), (-m, -m), (-m, m), (m, m)]) + m1 = helpers.extrude_poly(outer_poly=m1, height=0.1) + m1 = helpers.translate(m1, (0, 0, 6.0)) + key_cap = helpers.hull_from_shapes((k1, k2, m1)) else: - key_cap = hull_from_shapes((k1, k2)) + key_cap = helpers.hull_from_shapes((k1, k2)) - key_cap = translate(key_cap, (0, 0, 5 + plate_thickness)) + key_cap = helpers.translate(key_cap, (0, 0, 5 + shape_config['plate_thickness'])) - if show_pcbs: - key_cap = add([key_cap, key_pcb()]) + if shape_config['show_pcbs']: + key_cap = helpers.add([key_cap, key_pcb()]) return key_cap def key_pcb(): - shape = box(pcb_width, pcb_height, pcb_thickness) - shape = translate(shape, (0, 0, -pcb_thickness/2)) - hole = cylinder(pcb_hole_diameter/2, pcb_thickness+.2) - hole = translate(hole, (0, 0, -(pcb_thickness+.1)/2)) + shape = helpers.box(shape_config['pcb_width'], shape_config['pcb_height'], shape_config['pcb_thickness']) + shape = helpers.translate(shape, (0, 0, -shape_config['pcb_thickness']/2)) + hole = helpers.cylinder(shape_config['pcb_hole_diameter']/2, shape_config['pcb_thickness']+.2) + hole = helpers.translate(hole, (0, 0, -(shape_config['pcb_thickness']+.1)/2)) holes = [ - translate(hole, (pcb_hole_pattern_width/2, pcb_hole_pattern_height/2, 0)), - translate(hole, (-pcb_hole_pattern_width / 2, pcb_hole_pattern_height / 2, 0)), - translate(hole, (-pcb_hole_pattern_width / 2, -pcb_hole_pattern_height / 2, 0)), - translate(hole, (pcb_hole_pattern_width / 2, -pcb_hole_pattern_height / 2, 0)), + helpers.translate(hole, (shape_config['pcb_hole_pattern_width']/2, shape_config['pcb_hole_pattern_height']/2, 0)), + helpers.translate(hole, (-shape_config['pcb_hole_pattern_width'] / 2, shape_config['pcb_hole_pattern_height'] / 2, 0)), + helpers.translate(hole, (-shape_config['pcb_hole_pattern_width'] / 2, -shape_config['pcb_hole_pattern_height'] / 2, 0)), + helpers.translate(hole, (shape_config['pcb_hole_pattern_width'] / 2, -shape_config['pcb_hole_pattern_height'] / 2, 0)), ] - shape = difference(shape, holes) + shape = helpers.difference(shape, holes) return shape @@ -416,56 +417,56 @@ def apply_key_geometry( debugprint('apply_key_geometry()') - column_angle = beta * (centercol - column) + column_angle = shape_config['beta'] * (shape_config['centercol'] - column) if column_style == "orthographic": - column_z_delta = column_radius * (1 - np.cos(column_angle)) - shape = translate_fn(shape, [0, 0, -row_radius]) - shape = rotate_x_fn(shape, alpha * (centerrow - row)) - shape = translate_fn(shape, [0, 0, row_radius]) + column_z_delta = shape_config['column_radius'] * (1 - np.cos(column_angle)) + shape = translate_fn(shape, [0, 0, -shape_config['row_radius']]) + shape = rotate_x_fn(shape, shape_config['alpha'] * (shape_config['centerrow'] - row)) + shape = translate_fn(shape, [0, 0, shape_config['row_radius']]) shape = rotate_y_fn(shape, column_angle) shape = translate_fn( - shape, [-(column - centercol) * column_x_delta, 0, column_z_delta] + shape, [-(column - shape_config['centercol']) * shape_config['column_x_delta'], 0, column_z_delta] ) shape = translate_fn(shape, column_offset(column)) elif column_style == "fixed": - shape = rotate_y_fn(shape, fixed_angles[column]) - shape = translate_fn(shape, [fixed_x[column], 0, fixed_z[column]]) - shape = translate_fn(shape, [0, 0, -(row_radius + fixed_z[column])]) - shape = rotate_x_fn(shape, alpha * (centerrow - row)) - shape = translate_fn(shape, [0, 0, row_radius + fixed_z[column]]) - shape = rotate_y_fn(shape, fixed_tenting) + shape = rotate_y_fn(shape, shape_config['fixed_angles'][column]) + shape = translate_fn(shape, [shape_config['fixed_x'][column], 0, shape_config['fixed_z'][column]]) + shape = translate_fn(shape, [0, 0, -(shape_config['row_radius'] + shape_config['fixed_z'][column])]) + shape = rotate_x_fn(shape, shape_config['alpha'] * (shape_config['centerrow'] - row)) + shape = translate_fn(shape, [0, 0, shape_config['row_radius'] + shape_config['fixed_z'][column]]) + shape = rotate_y_fn(shape, shape_config['fixed_tenting']) shape = translate_fn(shape, [0, column_offset(column)[1], 0]) else: - shape = translate_fn(shape, [0, 0, -row_radius]) - shape = rotate_x_fn(shape, alpha * (centerrow - row)) - shape = translate_fn(shape, [0, 0, row_radius]) - shape = translate_fn(shape, [0, 0, -column_radius]) + shape = translate_fn(shape, [0, 0, -shape_config['row_radius']]) + shape = rotate_x_fn(shape, shape_config['alpha'] * (shape_config['centerrow'] - row)) + shape = translate_fn(shape, [0, 0, shape_config['row_radius']]) + shape = translate_fn(shape, [0, 0, -shape_config['column_radius']]) shape = rotate_y_fn(shape, column_angle) - shape = translate_fn(shape, [0, 0, column_radius]) + shape = translate_fn(shape, [0, 0, shape_config['column_radius']]) shape = translate_fn(shape, column_offset(column)) - shape = rotate_y_fn(shape, tenting_angle) - shape = translate_fn(shape, [0, 0, keyboard_z_offset]) + shape = rotate_y_fn(shape, shape_config['tenting_angle']) + shape = translate_fn(shape, [0, 0, shape_config['keyboard_z_offset']]) return shape def x_rot(shape, angle): # debugprint('x_rot()') - return rotate(shape, [rad2deg(angle), 0, 0]) + return helpers.rotate(shape, [rad2deg(angle), 0, 0]) def y_rot(shape, angle): # debugprint('y_rot()') - return rotate(shape, [0, rad2deg(angle), 0]) + return helpers.rotate(shape, [0, rad2deg(angle), 0]) def key_place(shape, column, row): debugprint('key_place()') - return apply_key_geometry(shape, translate, x_rot, y_rot, column, row) + return apply_key_geometry(shape, helpers.translate, x_rot, y_rot, column, row) def add_translate(shape, xyz): @@ -487,25 +488,25 @@ def key_holes(side="right"): debugprint('key_holes()') # hole = single_plate() holes = [] - for column in range(ncols): - for row in range(nrows): - if (column in [2, 3]) or (not row == lastrow): + for column in range(shape_config['ncols']): + for row in range(shape_config['nrows']): + if (column in [2, 3]) or (not row == shape_config['lastrow']): holes.append(key_place(single_plate(side=side), column, row)) - shape = union(holes) + shape = helpers.union(holes) return shape def caps(): caps = None - for column in range(ncols): - for row in range(nrows): - if (column in [2, 3]) or (not row == lastrow): + for column in range(shape_config['ncols']): + for row in range(shape_config['ncols']): + if (column in [2, 3]) or (not row == shape_config['lastrow']): if caps is None: caps = key_place(sa_cap(), column, row) else: - caps = add([caps, key_place(sa_cap(), column, row)]) + caps = helpers.add([caps, key_place(sa_cap(), column, row)]) return caps @@ -518,8 +519,8 @@ def caps(): def web_post(): debugprint('web_post()') - post = box(post_size, post_size, web_thickness) - post = translate(post, (0, 0, plate_thickness - (web_thickness / 2))) + post = helpers.box(shape_config['post_size'], shape_config['post_size'], shape_config['web_thickness']) + post = helpers.translate(post, (0, 0, shape_config['plate_thickness'] - (shape_config['web_thickness'] / 2))) return post @@ -529,7 +530,7 @@ def web_post_tr(wide=False): else: w_divide = 2.0 - return translate(web_post(), ((mount_width / w_divide) - post_adj, (mount_height / 2) - post_adj, 0)) + return helpers.translate(web_post(), ((shape_config['mount_width'] / w_divide) - shape_config['post_adj'], (shape_config['mount_height'] / 2) - shape_config['post_adj'], 0)) def web_post_tl(wide=False): @@ -537,7 +538,7 @@ def web_post_tl(wide=False): w_divide = 1.2 else: w_divide = 2.0 - return translate(web_post(), (-(mount_width / w_divide) + post_adj, (mount_height / 2) - post_adj, 0)) + return helpers.translate(web_post(), (-(shape_config['mount_width'] / w_divide) + shape_config['post_adj'], (shape_config['mount_height'] / 2) - shape_config['post_adj'], 0)) def web_post_bl(wide=False): @@ -545,7 +546,7 @@ def web_post_bl(wide=False): w_divide = 1.2 else: w_divide = 2.0 - return translate(web_post(), (-(mount_width / w_divide) + post_adj, -(mount_height / 2) + post_adj, 0)) + return helpers.translate(web_post(), (-(shape_config['mount_width'] / w_divide) + shape_config['post_adj'], -(shape_config['mount_height'] / 2) + shape_config['post_adj'], 0)) def web_post_br(wide=False): @@ -553,44 +554,44 @@ def web_post_br(wide=False): w_divide = 1.2 else: w_divide = 2.0 - return translate(web_post(), ((mount_width / w_divide) - post_adj, -(mount_height / 2) + post_adj, 0)) + return helpers.translate(web_post(), ((shape_config['mount_width'] / w_divide) - shape_config['post_adj'], -(shape_config['mount_height'] / 2) + shape_config['post_adj'], 0)) def connectors(): debugprint('connectors()') hulls = [] - for column in range(ncols - 1): - for row in range(lastrow): # need to consider last_row? - # for row in range(nrows): # need to consider last_row? + for column in range(shape_config['ncols'] - 1): + for row in range(shape_config['lastrow']): # need to consider last_row? + # for row in range(shape_config['nrows']): # need to consider last_row? places = [] places.append(key_place(web_post_tl(), column + 1, row)) places.append(key_place(web_post_tr(), column, row)) places.append(key_place(web_post_bl(), column + 1, row)) places.append(key_place(web_post_br(), column, row)) - hulls.append(triangle_hulls(places)) + hulls.append(helpers.triangle_hulls(places)) - for column in range(ncols): - # for row in range(nrows-1): - for row in range(cornerrow): + for column in range(shape_config['ncols']): + # for row in range(shape_config['nrows']-1): + for row in range(shape_config['cornerrow']): places = [] places.append(key_place(web_post_bl(), column, row)) places.append(key_place(web_post_br(), column, row)) places.append(key_place(web_post_tl(), column, row + 1)) places.append(key_place(web_post_tr(), column, row + 1)) - hulls.append(triangle_hulls(places)) + hulls.append(helpers.triangle_hulls(places)) - for column in range(ncols - 1): - # for row in range(nrows-1): # need to consider last_row? - for row in range(cornerrow): # need to consider last_row? + for column in range(shape_config['ncols'] - 1): + # for row in range(shape_config['nrows']-1): # need to consider last_row? + for row in range(shape_config['cornerrow']): # need to consider last_row? places = [] places.append(key_place(web_post_br(), column, row)) places.append(key_place(web_post_tr(), column, row + 1)) places.append(key_place(web_post_bl(), column + 1, row)) places.append(key_place(web_post_tl(), column + 1, row + 1)) - hulls.append(triangle_hulls(places)) + hulls.append(helpers.triangle_hulls(places)) - return union(hulls) + return helpers.union(hulls) ############ @@ -600,61 +601,61 @@ def connectors(): def thumborigin(): # debugprint('thumborigin()') - origin = key_position([mount_width / 2, -(mount_height / 2), 0], 1, cornerrow) + origin = key_position([shape_config['mount_width'] / 2, -(shape_config['mount_height'] / 2), 0], 1, shape_config['cornerrow']) for i in range(len(origin)): - origin[i] = origin[i] + thumb_offsets[i] + origin[i] = origin[i] + shape_config['thumb_offsets'][i] - if thumb_style == 'MINIDOX': - origin[1] = origin[1] - .4*(trackball_Usize-1)*sa_length + if shape_config['thumb_style'] == 'MINIDOX': + origin[1] = origin[1] - .4*(shape_config['trackball_Usize']-1)*shape_config['sa_length'] return origin def default_thumb_tl_place(shape): debugprint('thumb_tl_place()') - shape = rotate(shape, [7.5, -18, 10]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-32.5, -14.5, -2.5]) + shape = helpers.rotate(shape, [7.5, -18, 10]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-32.5, -14.5, -2.5]) return shape def default_thumb_tr_place(shape): debugprint('thumb_tr_place()') - shape = rotate(shape, [10, -15, 10]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-12, -16, 3]) + shape = helpers.rotate(shape, [10, -15, 10]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-12, -16, 3]) return shape def default_thumb_mr_place(shape): debugprint('thumb_mr_place()') - shape = rotate(shape, [-6, -34, 48]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-29, -40, -13]) + shape = helpers.rotate(shape, [-6, -34, 48]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-29, -40, -13]) return shape def default_thumb_ml_place(shape): debugprint('thumb_ml_place()') - shape = rotate(shape, [6, -34, 40]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-51, -25, -12]) + shape = helpers.rotate(shape, [6, -34, 40]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-51, -25, -12]) return shape def default_thumb_br_place(shape): debugprint('thumb_br_place()') - shape = rotate(shape, [-16, -33, 54]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-37.8, -55.3, -25.3]) + shape = helpers.rotate(shape, [-16, -33, 54]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-37.8, -55.3, -25.3]) return shape def default_thumb_bl_place(shape): debugprint('thumb_bl_place()') - shape = rotate(shape, [-4, -35, 52]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-56.3, -43.3, -23.5]) + shape = helpers.rotate(shape, [-4, -35, 52]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-56.3, -43.3, -23.5]) return shape @@ -662,28 +663,28 @@ def default_thumb_1x_layout(shape, cap=False): debugprint('thumb_1x_layout()') if cap: shape_list = [ - default_thumb_mr_place(rotate(shape, [0, 0, thumb_plate_mr_rotation])), - default_thumb_ml_place(rotate(shape, [0, 0, thumb_plate_ml_rotation])), - default_thumb_br_place(rotate(shape, [0, 0, thumb_plate_br_rotation])), - default_thumb_bl_place(rotate(shape, [0, 0, thumb_plate_bl_rotation])), + default_thumb_mr_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_mr_rotation']])), + default_thumb_ml_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_ml_rotation']])), + default_thumb_br_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_br_rotation']])), + default_thumb_bl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_bl_rotation']])), ] - if default_1U_cluster: - shape_list.append(default_thumb_tr_place(rotate(rotate(shape, (0, 0, 90)), [0, 0, thumb_plate_tr_rotation]))) - shape_list.append(default_thumb_tr_place(rotate(rotate(shape, (0, 0, 90)), [0, 0, thumb_plate_tr_rotation]))) - shape_list.append(default_thumb_tl_place(rotate(shape, [0, 0, thumb_plate_tl_rotation]))) - shapes = add(shape_list) + if shape_config['default_1U_cluster']: + shape_list.append(default_thumb_tr_place(helpers.rotate(helpers.rotate(shape, (0, 0, 90)), [0, 0, shape_config['thumb_plate_tr_rotation']]))) + shape_list.append(default_thumb_tr_place(helpers.rotate(helpers.rotate(shape, (0, 0, 90)), [0, 0, shape_config['thumb_plate_tr_rotation']]))) + shape_list.append(default_thumb_tl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tl_rotation']]))) + shapes = helpers.add(shape_list) else: shape_list = [ - default_thumb_mr_place(rotate(shape, [0, 0, thumb_plate_mr_rotation])), - default_thumb_ml_place(rotate(shape, [0, 0, thumb_plate_ml_rotation])), - default_thumb_br_place(rotate(shape, [0, 0, thumb_plate_br_rotation])), - default_thumb_bl_place(rotate(shape, [0, 0, thumb_plate_bl_rotation])), + default_thumb_mr_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_mr_rotation']])), + default_thumb_ml_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_ml_rotation']])), + default_thumb_br_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_br_rotation']])), + default_thumb_bl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_bl_rotation']])), ] - if default_1U_cluster: - shape_list.append(default_thumb_tr_place(rotate(rotate(shape, (0, 0, 90)), [0, 0, thumb_plate_tr_rotation]))) - shapes = union(shape_list) + if shape_config['default_1U_cluster']: + shape_list.append(default_thumb_tr_place(helpers.rotate(helpers.rotate(shape, (0, 0, 90)), [0, 0, shape_config['thumb_plate_tr_rotation']]))) + shapes = helpers.union(shape_list) return shapes @@ -691,70 +692,70 @@ def default_thumb_15x_layout(shape, cap=False, plate=True): debugprint('thumb_15x_layout()') if plate: if cap: - shape = rotate(shape, (0, 0, 90)) - cap_list = [default_thumb_tl_place(rotate(shape, [0, 0, thumb_plate_tl_rotation]))] - cap_list.append(default_thumb_tr_place(rotate(shape, [0, 0, thumb_plate_tr_rotation]))) - return add(cap_list) + shape = helpers.rotate(shape, (0, 0, 90)) + cap_list = [default_thumb_tl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tl_rotation']]))] + cap_list.append(default_thumb_tr_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tr_rotation']]))) + return helpers.add(cap_list) else: - shape_list = [default_thumb_tl_place(rotate(shape, [0, 0, thumb_plate_tl_rotation]))] - if not default_1U_cluster: - shape_list.append(default_thumb_tr_place(rotate(shape, [0, 0, thumb_plate_tr_rotation]))) - return union(shape_list) + shape_list = [default_thumb_tl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tl_rotation']]))] + if not shape_config['default_1U_cluster']: + shape_list.append(default_thumb_tr_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tr_rotation']]))) + return helpers.union(shape_list) else: if cap: - shape = rotate(shape, (0, 0, 90)) + shape = helpers.rotate(shape, (0, 0, 90)) shape_list = [ default_thumb_tl_place(shape), ] shape_list.append(default_thumb_tr_place(shape)) - return add(shape_list) + return helpers.add(shape_list) else: shape_list = [ default_thumb_tl_place(shape), ] - if not default_1U_cluster: + if not shape_config['default_1U_cluster']: shape_list.append(default_thumb_tr_place(shape)) - return union(shape_list) + return helpers.union(shape_list) def adjustable_plate_size(Usize=1.5): - return (Usize * sa_length - mount_height) / 2 + return (Usize * shape_config['sa_length'] - shape_config['mount_height']) / 2 def adjustable_plate_half(Usize=1.5): debugprint('double_plate()') adjustable_plate_height = adjustable_plate_size(Usize) - top_plate = box(mount_width, adjustable_plate_height, web_thickness) - top_plate = translate(top_plate, - [0, (adjustable_plate_height + mount_height) / 2, plate_thickness - (web_thickness / 2)] + top_plate = helpers.box(shape_config['mount_width'], adjustable_plate_height, shape_config['web_thickness']) + top_plate = helpers.translate(top_plate, + [0, (adjustable_plate_height + shape_config['mount_height']) / 2, shape_config['plate_thickness'] - (shape_config['web_thickness'] / 2)] ) return top_plate def adjustable_plate(Usize=1.5): debugprint('double_plate()') top_plate = adjustable_plate_half(Usize) - return union((top_plate, mirror(top_plate, 'XZ'))) + return helpers.union((top_plate, helpers.mirror(top_plate, 'XZ'))) def double_plate_half(): debugprint('double_plate()') - top_plate = box(mount_width, double_plate_height, web_thickness) - top_plate = translate(top_plate, - [0, (double_plate_height + mount_height) / 2, plate_thickness - (web_thickness / 2)] + top_plate = helpers.box(shape_config['mount_width'], shape_config['double_plate_height'], shape_config['web_thickness']) + top_plate = helpers.translate(top_plate, + [0, (shape_config['double_plate_height'] + shape_config['mount_height']) / 2, shape_config['plate_thickness'] - (shape_config['web_thickness'] / 2)] ) return top_plate def double_plate(): debugprint('double_plate()') top_plate = double_plate_half() - return union((top_plate, mirror(top_plate, 'XZ'))) + return helpers.union((top_plate, helpers.mirror(top_plate, 'XZ'))) def thumbcaps(side='right', style_override=None): if style_override is None: - _thumb_style = thumb_style + _thumb_style = shape_config['thumb_style'] else: _thumb_style = style_override @@ -766,13 +767,13 @@ def thumbcaps(side='right', style_override=None): return carbonfet_thumbcaps() elif "TRACKBALL" in _thumb_style: - if (side == ball_side or ball_side == 'both'): + if (side == shape_config['ball_side'] or shape_config['ball_side'] == 'both'): if _thumb_style == "TRACKBALL_ORBYL": return tbjs_thumbcaps() elif _thumb_style == "TRACKBALL_CJ": return tbcj_thumbcaps() else: - return thumbcaps(side, style_override=other_thumb) + return thumbcaps(side, style_override=shape_config['other_thumb']) else: return default_thumbcaps() @@ -780,7 +781,7 @@ def thumbcaps(side='right', style_override=None): def thumb(side="right", style_override=None): if style_override is None: - _thumb_style = thumb_style + _thumb_style = shape_config['thumb_style'] else: _thumb_style = style_override @@ -792,13 +793,13 @@ def thumb(side="right", style_override=None): return carbonfet_thumb(side) elif "TRACKBALL" in _thumb_style: - if (side == ball_side or ball_side == 'both'): + if (side == shape_config['ball_side'] or shape_config['ball_side'] == 'both'): if _thumb_style == "TRACKBALL_ORBYL": return tbjs_thumb(side) elif _thumb_style == "TRACKBALL_CJ": return tbcj_thumb(side) else: - return thumb(side, style_override=other_thumb) + return thumb(side, style_override=shape_config['other_thumb']) else: return default_thumb(side) @@ -806,7 +807,7 @@ def thumb(side="right", style_override=None): def thumb_connectors(side='right', style_override=None): if style_override is None: - _thumb_style = thumb_style + _thumb_style = shape_config['thumb_style'] else: _thumb_style = style_override @@ -818,13 +819,13 @@ def thumb_connectors(side='right', style_override=None): return carbonfet_thumb_connectors() elif "TRACKBALL" in _thumb_style: - if (side == ball_side or ball_side == 'both'): + if (side == shape_config['ball_side'] or shape_config['ball_side'] == 'both'): if _thumb_style == "TRACKBALL_ORBYL": return tbjs_thumb_connectors() elif _thumb_style == "TRACKBALL_CJ": return tbcj_thumb_connectors() else: - return thumb_connectors(side, style_override=other_thumb) + return thumb_connectors(side, style_override=shape_config['other_thumb']) else: return default_thumb_connectors() @@ -832,44 +833,44 @@ def thumb_connectors(side='right', style_override=None): def default_thumbcaps(): t1 = default_thumb_1x_layout(sa_cap(1), cap=True) - if not default_1U_cluster: - t1.add(default_thumb_15x_layout(sa_cap(1.5), cap=True)) + if not shape_config['default_1U_cluster']: + t1.helpers.add(default_thumb_15x_layout(sa_cap(1.5), cap=True)) return t1 def default_thumb(side="right"): print('thumb()') - shape = default_thumb_1x_layout(rotate(single_plate(side=side), (0, 0, -90))) - shape = union([shape, default_thumb_15x_layout(rotate(single_plate(side=side), (0, 0, -90)))]) - shape = union([shape, default_thumb_15x_layout(double_plate(), plate=False)]) + shape = default_thumb_1x_layout(helpers.rotate(single_plate(side=side), (0, 0, -90))) + shape = helpers.union([shape, default_thumb_15x_layout(helpers.rotate(single_plate(side=side), (0, 0, -90)))]) + shape = helpers.union([shape, default_thumb_15x_layout(double_plate(), plate=False)]) return shape def thumb_post_tr(): debugprint('thumb_post_tr()') - return translate(web_post(), - [(mount_width / 2) - post_adj, ((mount_height/2) + double_plate_height) - post_adj, 0] + return helpers.translate(web_post(), + [(shape_config['mount_width'] / 2) - shape_config['post_adj'], ((shape_config['mount_height']/2) + shape_config['double_plate_height']) - shape_config['post_adj'], 0] ) def thumb_post_tl(): debugprint('thumb_post_tl()') - return translate(web_post(), - [-(mount_width / 2) + post_adj, ((mount_height/2) + double_plate_height) - post_adj, 0] + return helpers.translate(web_post(), + [-(shape_config['mount_width'] / 2) + shape_config['post_adj'], ((shape_config['mount_height']/2) + shape_config['double_plate_height']) - shape_config['post_adj'], 0] ) def thumb_post_bl(): debugprint('thumb_post_bl()') - return translate(web_post(), - [-(mount_width / 2) + post_adj, -((mount_height/2) + double_plate_height) + post_adj, 0] + return helpers.translate(web_post(), + [-(shape_config['mount_width'] / 2) + shape_config['post_adj'], -((shape_config['mount_height']/2) + shape_config['double_plate_height']) + shape_config['post_adj'], 0] ) def thumb_post_br(): debugprint('thumb_post_br()') - return translate(web_post(), - [(mount_width / 2) - post_adj, -((mount_height/2) + double_plate_height) + post_adj, 0] + return helpers.translate(web_post(), + [(shape_config['mount_width'] / 2) - shape_config['post_adj'], -((shape_config['mount_height']/2) + shape_config['double_plate_height']) + shape_config['post_adj'], 0] ) @@ -878,9 +879,9 @@ def default_thumb_connectors(): hulls = [] # Top two - if default_1U_cluster: + if shape_config['default_1U_cluster']: hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ default_thumb_tl_place(thumb_post_tr()), default_thumb_tl_place(thumb_post_br()), @@ -891,7 +892,7 @@ def default_thumb_connectors(): ) else: hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ default_thumb_tl_place(thumb_post_tr()), default_thumb_tl_place(thumb_post_br()), @@ -903,7 +904,7 @@ def default_thumb_connectors(): # bottom two on the right hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ default_thumb_br_place(web_post_tr()), default_thumb_br_place(web_post_br()), @@ -915,7 +916,7 @@ def default_thumb_connectors(): # bottom two on the left hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ default_thumb_br_place(web_post_tr()), default_thumb_br_place(web_post_br()), @@ -926,7 +927,7 @@ def default_thumb_connectors(): ) # centers of the bottom four hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ default_thumb_bl_place(web_post_tr()), default_thumb_bl_place(web_post_br()), @@ -938,7 +939,7 @@ def default_thumb_connectors(): # top two to the middle two, starting on the left hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ default_thumb_br_place(web_post_tl()), default_thumb_bl_place(web_post_bl()), @@ -952,9 +953,9 @@ def default_thumb_connectors(): ) ) - if default_1U_cluster: + if shape_config['default_1U_cluster']: hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ default_thumb_tl_place(thumb_post_tl()), default_thumb_ml_place(web_post_tr()), @@ -971,7 +972,7 @@ def default_thumb_connectors(): else: # top two to the main keyboard, starting on the left hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ default_thumb_tl_place(thumb_post_tl()), default_thumb_ml_place(web_post_tr()), @@ -986,88 +987,88 @@ def default_thumb_connectors(): ) ) - if default_1U_cluster: + if shape_config['default_1U_cluster']: hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ default_thumb_tl_place(thumb_post_tl()), - key_place(web_post_bl(), 0, cornerrow), + key_place(web_post_bl(), 0, shape_config['cornerrow']), default_thumb_tl_place(thumb_post_tr()), - key_place(web_post_br(), 0, cornerrow), + key_place(web_post_br(), 0, shape_config['cornerrow']), default_thumb_tr_place(web_post_tl()), - key_place(web_post_bl(), 1, cornerrow), + key_place(web_post_bl(), 1, shape_config['cornerrow']), default_thumb_tr_place(web_post_tr()), - key_place(web_post_br(), 1, cornerrow), - key_place(web_post_tl(), 2, lastrow), - key_place(web_post_bl(), 2, lastrow), + key_place(web_post_br(), 1, shape_config['cornerrow']), + key_place(web_post_tl(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 2, shape_config['lastrow']), default_thumb_tr_place(web_post_tr()), - key_place(web_post_bl(), 2, lastrow), + key_place(web_post_bl(), 2, shape_config['lastrow']), default_thumb_tr_place(web_post_br()), - key_place(web_post_br(), 2, lastrow), - key_place(web_post_bl(), 3, lastrow), - key_place(web_post_tr(), 2, lastrow), - key_place(web_post_tl(), 3, lastrow), - key_place(web_post_bl(), 3, cornerrow), - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_br(), 3, cornerrow), - key_place(web_post_bl(), 4, cornerrow), + key_place(web_post_br(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 3, shape_config['lastrow']), + key_place(web_post_tr(), 2, shape_config['lastrow']), + key_place(web_post_tl(), 3, shape_config['lastrow']), + key_place(web_post_bl(), 3, shape_config['cornerrow']), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_br(), 3, shape_config['cornerrow']), + key_place(web_post_bl(), 4, shape_config['cornerrow']), ] ) ) else: hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ default_thumb_tl_place(thumb_post_tl()), - key_place(web_post_bl(), 0, cornerrow), + key_place(web_post_bl(), 0, shape_config['cornerrow']), default_thumb_tl_place(thumb_post_tr()), - key_place(web_post_br(), 0, cornerrow), + key_place(web_post_br(), 0, shape_config['cornerrow']), default_thumb_tr_place(thumb_post_tl()), - key_place(web_post_bl(), 1, cornerrow), + key_place(web_post_bl(), 1, shape_config['cornerrow']), default_thumb_tr_place(thumb_post_tr()), - key_place(web_post_br(), 1, cornerrow), - key_place(web_post_tl(), 2, lastrow), - key_place(web_post_bl(), 2, lastrow), + key_place(web_post_br(), 1, shape_config['cornerrow']), + key_place(web_post_tl(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 2, shape_config['lastrow']), default_thumb_tr_place(thumb_post_tr()), - key_place(web_post_bl(), 2, lastrow), + key_place(web_post_bl(), 2, shape_config['lastrow']), default_thumb_tr_place(thumb_post_br()), - key_place(web_post_br(), 2, lastrow), - key_place(web_post_bl(), 3, lastrow), - key_place(web_post_tr(), 2, lastrow), - key_place(web_post_tl(), 3, lastrow), - key_place(web_post_bl(), 3, cornerrow), - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_br(), 3, cornerrow), - key_place(web_post_bl(), 4, cornerrow), + key_place(web_post_br(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 3, shape_config['lastrow']), + key_place(web_post_tr(), 2, shape_config['lastrow']), + key_place(web_post_tl(), 3, shape_config['lastrow']), + key_place(web_post_bl(), 3, shape_config['cornerrow']), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_br(), 3, shape_config['cornerrow']), + key_place(web_post_bl(), 4, shape_config['cornerrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_br(), 1, cornerrow), - key_place(web_post_tl(), 2, lastrow), - key_place(web_post_bl(), 2, cornerrow), - key_place(web_post_tr(), 2, lastrow), - key_place(web_post_br(), 2, cornerrow), - key_place(web_post_bl(), 3, cornerrow), + key_place(web_post_br(), 1, shape_config['cornerrow']), + key_place(web_post_tl(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 2, shape_config['cornerrow']), + key_place(web_post_tr(), 2, shape_config['lastrow']), + key_place(web_post_br(), 2, shape_config['cornerrow']), + key_place(web_post_bl(), 3, shape_config['cornerrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_br(), 3, lastrow), - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_bl(), 4, cornerrow), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_br(), 3, shape_config['lastrow']), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_bl(), 4, shape_config['cornerrow']), ] ) ) - return union(hulls) + return helpers.union(hulls) ############################ # MINI THUMB CLUSTER @@ -1075,87 +1076,87 @@ def default_thumb_connectors(): def mini_thumb_tr_place(shape): - shape = rotate(shape, [14, -15, 10]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-15, -10, 5]) + shape = helpers.rotate(shape, [14, -15, 10]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-15, -10, 5]) return shape def mini_thumb_tl_place(shape): - shape = rotate(shape, [10, -23, 25]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-35, -16, -2]) + shape = helpers.rotate(shape, [10, -23, 25]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-35, -16, -2]) return shape def mini_thumb_mr_place(shape): - shape = rotate(shape, [10, -23, 25]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-23, -34, -6]) + shape = helpers.rotate(shape, [10, -23, 25]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-23, -34, -6]) return shape def mini_thumb_br_place(shape): - shape = rotate(shape, [6, -34, 35]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-39, -43, -16]) + shape = helpers.rotate(shape, [6, -34, 35]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-39, -43, -16]) return shape def mini_thumb_bl_place(shape): - shape = rotate(shape, [6, -32, 35]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-51, -25, -11.5]) + shape = helpers.rotate(shape, [6, -32, 35]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-51, -25, -11.5]) return shape def mini_thumb_1x_layout(shape): - return union([ - mini_thumb_mr_place(rotate(shape, [0, 0, thumb_plate_mr_rotation])), - mini_thumb_br_place(rotate(shape, [0, 0, thumb_plate_br_rotation])), - mini_thumb_tl_place(rotate(shape, [0, 0, thumb_plate_tl_rotation])), - mini_thumb_bl_place(rotate(shape, [0, 0, thumb_plate_bl_rotation])), + return helpers.union([ + mini_thumb_mr_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_mr_rotation']])), + mini_thumb_br_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_br_rotation']])), + mini_thumb_tl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tl_rotation']])), + mini_thumb_bl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_bl_rotation']])), ]) def mini_thumb_15x_layout(shape): - return union([mini_thumb_tr_place(rotate(shape, [0, 0, thumb_plate_tr_rotation]))]) + return helpers.union([mini_thumb_tr_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tr_rotation']]))]) def mini_thumbcaps(): t1 = mini_thumb_1x_layout(sa_cap(1)) - t15 = mini_thumb_15x_layout(rotate(sa_cap(1), [0, 0, rad2deg(pi / 2)])) - return t1.add(t15) + t15 = mini_thumb_15x_layout(helpers.rotate(sa_cap(1), [0, 0, rad2deg(pi / 2)])) + return t1.helpers.add(t15) def mini_thumb(side="right"): shape = mini_thumb_1x_layout(single_plate(side=side)) - shape = union([shape, mini_thumb_15x_layout(single_plate(side=side))]) + shape = helpers.union([shape, mini_thumb_15x_layout(single_plate(side=side))]) return shape def mini_thumb_post_tr(): - return translate(web_post(), - [(mount_width / 2) - post_adj, (mount_height / 2) - post_adj, 0] + return helpers.translate(web_post(), + [(shape_config['mount_width'] / 2) - shape_config['post_adj'], (shape_config['mount_height'] / 2) - shape_config['post_adj'], 0] ) def mini_thumb_post_tl(): - return translate(web_post(), - [-(mount_width / 2) + post_adj, (mount_height / 2) - post_adj, 0] + return helpers.translate(web_post(), + [-(shape_config['mount_width'] / 2) + shape_config['post_adj'], (shape_config['mount_height'] / 2) - shape_config['post_adj'], 0] ) def mini_thumb_post_bl(): - return translate(web_post(), - [-(mount_width / 2) + post_adj, -(mount_height / 2) + post_adj, 0] + return helpers.translate(web_post(), + [-(shape_config['mount_width'] / 2) + shape_config['post_adj'], -(shape_config['mount_height'] / 2) + shape_config['post_adj'], 0] ) def mini_thumb_post_br(): - return translate(web_post(), - [(mount_width / 2) - post_adj, -(mount_height / 2) + post_adj, 0] + return helpers.translate(web_post(), + [(shape_config['mount_width'] / 2) - shape_config['post_adj'], -(shape_config['mount_height'] / 2) + shape_config['post_adj'], 0] ) @@ -1164,7 +1165,7 @@ def mini_thumb_connectors(): # Top two hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ mini_thumb_tl_place(web_post_tr()), mini_thumb_tl_place(web_post_br()), @@ -1176,7 +1177,7 @@ def mini_thumb_connectors(): # bottom two on the right hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ mini_thumb_br_place(web_post_tr()), mini_thumb_br_place(web_post_br()), @@ -1188,7 +1189,7 @@ def mini_thumb_connectors(): # bottom two on the left hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ mini_thumb_mr_place(web_post_tr()), mini_thumb_mr_place(web_post_br()), @@ -1199,7 +1200,7 @@ def mini_thumb_connectors(): # between top and bottom row hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ mini_thumb_br_place(web_post_tl()), mini_thumb_bl_place(web_post_bl()), @@ -1217,7 +1218,7 @@ def mini_thumb_connectors(): ) # top two to the main keyboard, starting on the left hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ mini_thumb_tl_place(web_post_tl()), mini_thumb_bl_place(web_post_tr()), @@ -1232,64 +1233,64 @@ def mini_thumb_connectors(): ) # top two to the main keyboard, starting on the left hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ mini_thumb_tl_place(web_post_tl()), - key_place(web_post_bl(), 0, cornerrow), + key_place(web_post_bl(), 0, shape_config['cornerrow']), mini_thumb_tl_place(web_post_tr()), - key_place(web_post_br(), 0, cornerrow), + key_place(web_post_br(), 0, shape_config['cornerrow']), mini_thumb_tr_place(mini_thumb_post_tl()), - key_place(web_post_bl(), 1, cornerrow), + key_place(web_post_bl(), 1, shape_config['cornerrow']), mini_thumb_tr_place(mini_thumb_post_tr()), - key_place(web_post_br(), 1, cornerrow), - key_place(web_post_tl(), 2, lastrow), - key_place(web_post_bl(), 2, lastrow), + key_place(web_post_br(), 1, shape_config['cornerrow']), + key_place(web_post_tl(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 2, shape_config['lastrow']), mini_thumb_tr_place(mini_thumb_post_tr()), - key_place(web_post_bl(), 2, lastrow), + key_place(web_post_bl(), 2, shape_config['lastrow']), mini_thumb_tr_place(mini_thumb_post_br()), - key_place(web_post_br(), 2, lastrow), - key_place(web_post_bl(), 3, lastrow), - key_place(web_post_tr(), 2, lastrow), - key_place(web_post_tl(), 3, lastrow), - key_place(web_post_bl(), 3, cornerrow), - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_br(), 3, cornerrow), + key_place(web_post_br(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 3, shape_config['lastrow']), + key_place(web_post_tr(), 2, shape_config['lastrow']), + key_place(web_post_tl(), 3, shape_config['lastrow']), + key_place(web_post_bl(), 3, shape_config['cornerrow']), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_br(), 3, shape_config['cornerrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_br(), 3, lastrow), - key_place(web_post_bl(), 4, cornerrow), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_br(), 3, shape_config['lastrow']), + key_place(web_post_bl(), 4, shape_config['cornerrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_br(), 3, cornerrow), - key_place(web_post_bl(), 4, cornerrow), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_br(), 3, shape_config['cornerrow']), + key_place(web_post_bl(), 4, shape_config['cornerrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_br(), 1, cornerrow), - key_place(web_post_tl(), 2, lastrow), - key_place(web_post_bl(), 2, cornerrow), - key_place(web_post_tr(), 2, lastrow), - key_place(web_post_br(), 2, cornerrow), - key_place(web_post_bl(), 3, cornerrow), + key_place(web_post_br(), 1, shape_config['cornerrow']), + key_place(web_post_tl(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 2, shape_config['cornerrow']), + key_place(web_post_tr(), 2, shape_config['lastrow']), + key_place(web_post_br(), 2, shape_config['cornerrow']), + key_place(web_post_bl(), 3, shape_config['cornerrow']), ] ) ) - return union(hulls) + return helpers.union(hulls) ############################ @@ -1297,69 +1298,69 @@ def mini_thumb_connectors(): ############################ def minidox_thumb_tl_place(shape): - shape = rotate(shape, [10, -23, 25]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-35, -16, -2]) + shape = helpers.rotate(shape, [10, -23, 25]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-35, -16, -2]) return shape def minidox_thumb_tr_place(shape): - shape = rotate(shape, [14, -15, 10]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-15, -10, 5]) + shape = helpers.rotate(shape, [14, -15, 10]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-15, -10, 5]) return shape def minidox_thumb_ml_place(shape): - shape = rotate(shape, [6, -34, 40]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-53, -26, -12]) + shape = helpers.rotate(shape, [6, -34, 40]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-53, -26, -12]) return shape def minidox_thumb_mr_place(shape): - shape = rotate(shape, [10, -23, 25]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-23, -34, -6]) + shape = helpers.rotate(shape, [10, -23, 25]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-23, -34, -6]) return shape def minidox_thumb_bl_place(shape): - shape = rotate(shape, [6, -32, 35]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-51, -25, -11.5]) + shape = helpers.rotate(shape, [6, -32, 35]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-51, -25, -11.5]) return shape def minidox_thumb_br_place(shape): - shape = rotate(shape, [6, -32, 35]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-51, -25, -11.5]) + shape = helpers.rotate(shape, [6, -32, 35]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-51, -25, -11.5]) return shape def minidox_thumb_1x_layout(shape): - return union([ - minidox_thumb_tr_place(rotate(shape, [0, 0, thumb_plate_tr_rotation])), - minidox_thumb_tl_place(rotate(shape, [0, 0, thumb_plate_tl_rotation])), - minidox_thumb_ml_place(rotate(shape, [0, 0, thumb_plate_ml_rotation])), + return helpers.union([ + minidox_thumb_tr_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tr_rotation']])), + minidox_thumb_tl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tl_rotation']])), + minidox_thumb_ml_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_ml_rotation']])), ]) def minidox_thumb_fx_layout(shape): - return union([ - minidox_thumb_tr_place(rotate(shape, [0, 0, thumb_plate_tr_rotation])), - minidox_thumb_tl_place(rotate(shape, [0, 0, thumb_plate_tl_rotation])), - minidox_thumb_ml_place(rotate(shape, [0, 0, thumb_plate_ml_rotation])), + return helpers.union([ + minidox_thumb_tr_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tr_rotation']])), + minidox_thumb_tl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tl_rotation']])), + minidox_thumb_ml_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_ml_rotation']])), ]) def minidox_thumbcaps(): t1 = minidox_thumb_1x_layout(sa_cap(1)) - # t1.add(minidox_thumb_15x_layout(rotate(sa_cap(1), [0, 0, rad2deg(pi / 2)]))) + # t1.helpers.add(minidox_thumb_15x_layout(helpers.rotate(sa_cap(1), [0, 0, rad2deg(pi / 2)]))) return t1 def minidox_thumb(side="right"): - shape = minidox_thumb_fx_layout(rotate(single_plate(side=side), [0.0, 0.0, -90])) - shape = union([shape, minidox_thumb_fx_layout(adjustable_plate(minidox_Usize))]) + shape = minidox_thumb_fx_layout(helpers.rotate(single_plate(side=side), [0.0, 0.0, -90])) + shape = helpers.union([shape, minidox_thumb_fx_layout(adjustable_plate(shape_config['minidox_Usize']))]) # shape = minidox_thumb_1x_layout(single_plate(side=side)) @@ -1368,29 +1369,29 @@ def minidox_thumb(side="right"): def minidox_thumb_post_tr(): debugprint('thumb_post_tr()') - return translate(web_post(), - [(mount_width / 2) - post_adj, ((mount_height/2) + adjustable_plate_size(minidox_Usize)) - post_adj, 0] + return helpers.translate(web_post(), + [(shape_config['mount_width'] / 2) - shape_config['post_adj'], ((shape_config['mount_height']/2) + adjustable_plate_size(shape_config['minidox_Usize'])) - shape_config['post_adj'], 0] ) def minidox_thumb_post_tl(): debugprint('thumb_post_tl()') - return translate(web_post(), - [-(mount_width / 2) + post_adj, ((mount_height/2) + adjustable_plate_size(minidox_Usize)) - post_adj, 0] + return helpers.translate(web_post(), + [-(shape_config['mount_width'] / 2) + shape_config['post_adj'], ((shape_config['mount_height']/2) + adjustable_plate_size(shape_config['minidox_Usize'])) - shape_config['post_adj'], 0] ) def minidox_thumb_post_bl(): debugprint('thumb_post_bl()') - return translate(web_post(), - [-(mount_width / 2) + post_adj, -((mount_height/2) + adjustable_plate_size(minidox_Usize)) + post_adj, 0] + return helpers.translate(web_post(), + [-(shape_config['mount_width'] / 2) + shape_config['post_adj'], -((shape_config['mount_height']/2) + adjustable_plate_size(shape_config['minidox_Usize'])) + shape_config['post_adj'], 0] ) def minidox_thumb_post_br(): debugprint('thumb_post_br()') - return translate(web_post(), - [(mount_width / 2) - post_adj, -((mount_height/2) + adjustable_plate_size(minidox_Usize)) + post_adj, 0] + return helpers.translate(web_post(), + [(shape_config['mount_width'] / 2) - shape_config['post_adj'], -((shape_config['mount_height']/2) + adjustable_plate_size(shape_config['minidox_Usize'])) + shape_config['post_adj'], 0] ) @@ -1399,7 +1400,7 @@ def minidox_thumb_connectors(): # Top two hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ minidox_thumb_tl_place(minidox_thumb_post_tr()), minidox_thumb_tl_place(minidox_thumb_post_br()), @@ -1411,7 +1412,7 @@ def minidox_thumb_connectors(): # bottom two on the right hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ minidox_thumb_tl_place(minidox_thumb_post_tl()), minidox_thumb_tl_place(minidox_thumb_post_bl()), @@ -1424,64 +1425,64 @@ def minidox_thumb_connectors(): # top two to the main keyboard, starting on the left hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ minidox_thumb_tl_place(minidox_thumb_post_tl()), - key_place(web_post_bl(), 0, cornerrow), + key_place(web_post_bl(), 0, shape_config['cornerrow']), minidox_thumb_tl_place(minidox_thumb_post_tr()), - key_place(web_post_br(), 0, cornerrow), + key_place(web_post_br(), 0, shape_config['cornerrow']), minidox_thumb_tr_place(minidox_thumb_post_tl()), - key_place(web_post_bl(), 1, cornerrow), + key_place(web_post_bl(), 1, shape_config['cornerrow']), minidox_thumb_tr_place(minidox_thumb_post_tr()), - key_place(web_post_br(), 1, cornerrow), - key_place(web_post_tl(), 2, lastrow), - key_place(web_post_bl(), 2, lastrow), + key_place(web_post_br(), 1, shape_config['cornerrow']), + key_place(web_post_tl(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 2, shape_config['lastrow']), minidox_thumb_tr_place(minidox_thumb_post_tr()), - key_place(web_post_bl(), 2, lastrow), + key_place(web_post_bl(), 2, shape_config['lastrow']), minidox_thumb_tr_place(minidox_thumb_post_br()), - key_place(web_post_br(), 2, lastrow), - key_place(web_post_bl(), 3, lastrow), - key_place(web_post_tr(), 2, lastrow), - key_place(web_post_tl(), 3, lastrow), - key_place(web_post_bl(), 3, cornerrow), - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_br(), 3, cornerrow), + key_place(web_post_br(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 3, shape_config['lastrow']), + key_place(web_post_tr(), 2, shape_config['lastrow']), + key_place(web_post_tl(), 3, shape_config['lastrow']), + key_place(web_post_bl(), 3, shape_config['cornerrow']), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_br(), 3, shape_config['cornerrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_br(), 3, lastrow), - key_place(web_post_bl(), 4, cornerrow), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_br(), 3, shape_config['lastrow']), + key_place(web_post_bl(), 4, shape_config['cornerrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_br(), 3, cornerrow), - key_place(web_post_bl(), 4, cornerrow), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_br(), 3, shape_config['cornerrow']), + key_place(web_post_bl(), 4, shape_config['cornerrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_br(), 1, cornerrow), - key_place(web_post_tl(), 2, lastrow), - key_place(web_post_bl(), 2, cornerrow), - key_place(web_post_tr(), 2, lastrow), - key_place(web_post_br(), 2, cornerrow), - key_place(web_post_bl(), 3, cornerrow), + key_place(web_post_br(), 1, shape_config['cornerrow']), + key_place(web_post_tl(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 2, shape_config['cornerrow']), + key_place(web_post_tr(), 2, shape_config['lastrow']), + key_place(web_post_br(), 2, shape_config['cornerrow']), + key_place(web_post_bl(), 3, shape_config['cornerrow']), ] ) ) - return union(hulls) + return helpers.union(hulls) ############################ @@ -1490,59 +1491,59 @@ def minidox_thumb_connectors(): def carbonfet_thumb_tl_place(shape): - shape = rotate(shape, [10, -24, 10]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-13, -9.8, 4]) + shape = helpers.rotate(shape, [10, -24, 10]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-13, -9.8, 4]) return shape def carbonfet_thumb_tr_place(shape): - shape = rotate(shape, [6, -25, 10]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-7.5, -29.5, 0]) + shape = helpers.rotate(shape, [6, -25, 10]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-7.5, -29.5, 0]) return shape def carbonfet_thumb_ml_place(shape): - shape = rotate(shape, [8, -31, 14]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-30.5, -17, -6]) + shape = helpers.rotate(shape, [8, -31, 14]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-30.5, -17, -6]) return shape def carbonfet_thumb_mr_place(shape): - shape = rotate(shape, [4, -31, 14]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-22.2, -41, -10.3]) + shape = helpers.rotate(shape, [4, -31, 14]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-22.2, -41, -10.3]) return shape def carbonfet_thumb_br_place(shape): - shape = rotate(shape, [2, -37, 18]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-37, -46.4, -22]) + shape = helpers.rotate(shape, [2, -37, 18]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-37, -46.4, -22]) return shape def carbonfet_thumb_bl_place(shape): - shape = rotate(shape, [6, -37, 18]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-47, -23, -19]) + shape = helpers.rotate(shape, [6, -37, 18]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-47, -23, -19]) return shape def carbonfet_thumb_1x_layout(shape): - return union([ - carbonfet_thumb_tr_place(rotate(shape, [0, 0, thumb_plate_tr_rotation])), - carbonfet_thumb_mr_place(rotate(shape, [0, 0, thumb_plate_mr_rotation])), - carbonfet_thumb_br_place(rotate(shape, [0, 0, thumb_plate_br_rotation])), - carbonfet_thumb_tl_place(rotate(shape, [0, 0, thumb_plate_tl_rotation])), + return helpers.union([ + carbonfet_thumb_tr_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tr_rotation']])), + carbonfet_thumb_mr_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_mr_rotation']])), + carbonfet_thumb_br_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_br_rotation']])), + carbonfet_thumb_tl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tl_rotation']])), ]) def carbonfet_thumb_15x_layout(shape, plate=True): if plate: - return union([ - carbonfet_thumb_bl_place(rotate(shape, [0, 0, thumb_plate_bl_rotation])), - carbonfet_thumb_ml_place(rotate(shape, [0, 0, thumb_plate_ml_rotation])) + return helpers.union([ + carbonfet_thumb_bl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_bl_rotation']])), + carbonfet_thumb_ml_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_ml_rotation']])) ]) else: - return union([ + return helpers.union([ carbonfet_thumb_bl_place(shape), carbonfet_thumb_ml_place(shape) ]) @@ -1550,38 +1551,38 @@ def carbonfet_thumb_15x_layout(shape, plate=True): def carbonfet_thumbcaps(): t1 = carbonfet_thumb_1x_layout(sa_cap(1)) - t15 = carbonfet_thumb_15x_layout(rotate(sa_cap(1.5), [0, 0, rad2deg(pi / 2)])) - return t1.add(t15) + t15 = carbonfet_thumb_15x_layout(helpers.rotate(sa_cap(1.5), [0, 0, rad2deg(pi / 2)])) + return t1.helpers.add(t15) def carbonfet_thumb(side="right"): shape = carbonfet_thumb_1x_layout(single_plate(side=side)) - shape = union([shape, carbonfet_thumb_15x_layout(double_plate_half(), plate=False)]) - shape = union([shape, carbonfet_thumb_15x_layout(single_plate(side=side))]) + shape = helpers.union([shape, carbonfet_thumb_15x_layout(double_plate_half(), plate=False)]) + shape = helpers.union([shape, carbonfet_thumb_15x_layout(single_plate(side=side))]) return shape def carbonfet_thumb_post_tr(): - return translate(web_post(), - [(mount_width / 2) - post_adj, (mount_height / 1.15) - post_adj, 0] + return helpers.translate(web_post(), + [(shape_config['mount_width'] / 2) - shape_config['post_adj'], (shape_config['mount_height'] / 1.15) - shape_config['post_adj'], 0] ) def carbonfet_thumb_post_tl(): - return translate(web_post(), - [-(mount_width / 2) + post_adj, (mount_height / 1.15) - post_adj, 0] + return helpers.translate(web_post(), + [-(shape_config['mount_width'] / 2) + shape_config['post_adj'], (shape_config['mount_height'] / 1.15) - shape_config['post_adj'], 0] ) def carbonfet_thumb_post_bl(): - return translate(web_post(), - [-(mount_width / 2) + post_adj, -(mount_height / 1.15) + post_adj, 0] + return helpers.translate(web_post(), + [-(shape_config['mount_width'] / 2) + shape_config['post_adj'], -(shape_config['mount_height'] / 1.15) + shape_config['post_adj'], 0] ) def carbonfet_thumb_post_br(): - return translate(web_post(), - [(mount_width / 2) - post_adj, -(mount_height / 2) + post_adj, 0] + return helpers.translate(web_post(), + [(shape_config['mount_width'] / 2) - shape_config['post_adj'], -(shape_config['mount_height'] / 2) + shape_config['post_adj'], 0] ) def carbonfet_thumb_connectors(): @@ -1589,7 +1590,7 @@ def carbonfet_thumb_connectors(): # Top two hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ carbonfet_thumb_tl_place(web_post_tl()), carbonfet_thumb_tl_place(web_post_bl()), @@ -1600,7 +1601,7 @@ def carbonfet_thumb_connectors(): ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ carbonfet_thumb_ml_place(carbonfet_thumb_post_tl()), carbonfet_thumb_ml_place(web_post_bl()), @@ -1612,7 +1613,7 @@ def carbonfet_thumb_connectors(): # bottom two on the right hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ carbonfet_thumb_br_place(web_post_tr()), carbonfet_thumb_br_place(web_post_br()), @@ -1624,7 +1625,7 @@ def carbonfet_thumb_connectors(): # bottom two on the left hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ carbonfet_thumb_mr_place(web_post_tr()), carbonfet_thumb_mr_place(web_post_br()), @@ -1634,7 +1635,7 @@ def carbonfet_thumb_connectors(): ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ carbonfet_thumb_tr_place(web_post_br()), carbonfet_thumb_tr_place(web_post_bl()), @@ -1645,7 +1646,7 @@ def carbonfet_thumb_connectors(): # between top and bottom row hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ carbonfet_thumb_br_place(web_post_tl()), carbonfet_thumb_bl_place(web_post_bl()), @@ -1664,23 +1665,23 @@ def carbonfet_thumb_connectors(): ) # top two to the main keyboard, starting on the left hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ carbonfet_thumb_ml_place(carbonfet_thumb_post_tl()), - key_place(web_post_bl(), 0, cornerrow), + key_place(web_post_bl(), 0, shape_config['cornerrow']), carbonfet_thumb_ml_place(carbonfet_thumb_post_tr()), - key_place(web_post_br(), 0, cornerrow), + key_place(web_post_br(), 0, shape_config['cornerrow']), carbonfet_thumb_tl_place(web_post_tl()), - key_place(web_post_bl(), 1, cornerrow), + key_place(web_post_bl(), 1, shape_config['cornerrow']), carbonfet_thumb_tl_place(web_post_tr()), - key_place(web_post_br(), 1, cornerrow), - key_place(web_post_tl(), 2, lastrow), - key_place(web_post_bl(), 2, lastrow), + key_place(web_post_br(), 1, shape_config['cornerrow']), + key_place(web_post_tl(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 2, shape_config['lastrow']), carbonfet_thumb_tl_place(web_post_tr()), - key_place(web_post_bl(), 2, lastrow), + key_place(web_post_bl(), 2, shape_config['lastrow']), carbonfet_thumb_tl_place(web_post_br()), - key_place(web_post_br(), 2, lastrow), - key_place(web_post_bl(), 3, lastrow), + key_place(web_post_br(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 3, shape_config['lastrow']), carbonfet_thumb_tl_place(web_post_br()), carbonfet_thumb_tr_place(web_post_tr()), ] @@ -1688,72 +1689,72 @@ def carbonfet_thumb_connectors(): ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_br(), 3, cornerrow), - key_place(web_post_tl(), 3, lastrow), - key_place(web_post_bl(), 3, cornerrow), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_br(), 3, shape_config['cornerrow']), + key_place(web_post_tl(), 3, shape_config['lastrow']), + key_place(web_post_bl(), 3, shape_config['cornerrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_tr(), 2, lastrow), - key_place(web_post_br(), 2, lastrow), - key_place(web_post_tl(), 3, lastrow), - key_place(web_post_bl(), 3, lastrow), + key_place(web_post_tr(), 2, shape_config['lastrow']), + key_place(web_post_br(), 2, shape_config['lastrow']), + key_place(web_post_tl(), 3, shape_config['lastrow']), + key_place(web_post_bl(), 3, shape_config['lastrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ carbonfet_thumb_tr_place(web_post_br()), carbonfet_thumb_tr_place(web_post_tr()), - key_place(web_post_bl(), 3, lastrow), + key_place(web_post_bl(), 3, shape_config['lastrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_br(), 1, cornerrow), - key_place(web_post_tl(), 2, lastrow), - key_place(web_post_bl(), 2, cornerrow), - key_place(web_post_tr(), 2, lastrow), - key_place(web_post_br(), 2, cornerrow), - key_place(web_post_tl(), 3, lastrow), - key_place(web_post_bl(), 3, cornerrow), + key_place(web_post_br(), 1, shape_config['cornerrow']), + key_place(web_post_tl(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 2, shape_config['cornerrow']), + key_place(web_post_tr(), 2, shape_config['lastrow']), + key_place(web_post_br(), 2, shape_config['cornerrow']), + key_place(web_post_tl(), 3, shape_config['lastrow']), + key_place(web_post_bl(), 3, shape_config['cornerrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_br(), 3, lastrow), - key_place(web_post_bl(), 4, cornerrow), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_br(), 3, shape_config['lastrow']), + key_place(web_post_bl(), 4, shape_config['cornerrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_br(), 3, cornerrow), - key_place(web_post_bl(), 4, cornerrow), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_br(), 3, shape_config['cornerrow']), + key_place(web_post_bl(), 4, shape_config['cornerrow']), ] ) ) - return union(hulls) + return helpers.union(hulls) ############################ @@ -1764,215 +1765,215 @@ def tbjs_thumb_position_rotation(): rot = [10, -15, 5] pos = thumborigin() # Changes size based on key diameter around ball, shifting off of the top left cluster key. - shift = [-.9*tbjs_key_diameter/2+27-42, -.1*tbjs_key_diameter/2+3-20, -5] + shift = [-.9*shape_config['tbjs_key_diameter']/2+27-42, -.1*shape_config['tbjs_key_diameter']/2+3-20, -5] for i in range(len(pos)): - pos[i] = pos[i] + shift[i] + tbjs_translation_offset[i] + pos[i] = pos[i] + shift[i] + shape_config['tbjs_translation_offset'][i] for i in range(len(rot)): - rot[i] = rot[i] + tbjs_rotation_offset[i] + rot[i] = rot[i] + shape_config['tbjs_rotation_offset'][i] return pos, rot def tbjs_place(shape): pos, rot = tbjs_thumb_position_rotation() - shape = rotate(shape, rot) - shape = translate(shape, pos) + shape = helpers.rotate(shape, rot) + shape = helpers.translate(shape, pos) return shape def tbjs_thumb_tl_place(shape): debugprint('thumb_tr_place()') # Modifying to make a "ring" of keys - shape = rotate(shape, [0, 0, 0]) - t_off = tbjs_key_translation_offsets[0] - shape = rotate(shape, tbjs_key_rotation_offsets[0]) - shape = translate(shape, (t_off[0], t_off[1]+tbjs_key_diameter/2, t_off[2])) - shape = rotate(shape, [0,0,-80]) + shape = helpers.rotate(shape, [0, 0, 0]) + t_off = shape_config['tbjs_key_translation_offsets'][0] + shape = helpers.rotate(shape, shape_config['tbjs_key_rotation_offsets'][0]) + shape = helpers.translate(shape, (t_off[0], t_off[1]+shape_config['tbjs_key_diameter']/2, t_off[2])) + shape = helpers.rotate(shape, [0,0,-80]) shape = tbjs_place(shape) - # shape = rotate(shape, [5, 10, -65]) - # shape = translate(shape, thumborigin()) - # shape = translate(shape, [-14, -9, 0]) + # shape = helpers.rotate(shape, [5, 10, -65]) + # shape = helpers.translate(shape, thumborigin()) + # shape = helpers.translate(shape, [-14, -9, 0]) return shape def tbjs_thumb_mr_place(shape): debugprint('thumb_mr_place()') - shape = rotate(shape, [0, 0, 0]) - shape = rotate(shape, tbjs_key_rotation_offsets[1]) - t_off = tbjs_key_translation_offsets[1] - shape = translate(shape, (t_off[0], t_off[1]+tbjs_key_diameter/2, t_off[2])) - shape = rotate(shape, [0,0,-130]) + shape = helpers.rotate(shape, [0, 0, 0]) + shape = helpers.rotate(shape, shape_config['tbjs_key_rotation_offsets'][1]) + t_off = shape_config['tbjs_key_translation_offsets'][1] + shape = helpers.translate(shape, (t_off[0], t_off[1]+shape_config['tbjs_key_diameter']/2, t_off[2])) + shape = helpers.rotate(shape, [0,0,-130]) shape = tbjs_place(shape) - # shape = rotate(shape, [7, 20, -105]) - # shape = translate(shape, thumborigin()) - # shape = translate(shape, [-12, -32, -5]) + # shape = helpers.rotate(shape, [7, 20, -105]) + # shape = helpers.translate(shape, thumborigin()) + # shape = helpers.translate(shape, [-12, -32, -5]) return shape def tbjs_thumb_br_place(shape): debugprint('thumb_br_place()') - shape = rotate(shape, [0, 0, 180]) - shape = rotate(shape, tbjs_key_rotation_offsets[2]) - t_off = tbjs_key_translation_offsets[2] - shape = translate(shape, (t_off[0], t_off[1]+tbjs_key_diameter/2, t_off[2])) - shape = rotate(shape, [0,0,-180]) + shape = helpers.rotate(shape, [0, 0, 180]) + shape = helpers.rotate(shape, shape_config['tbjs_key_rotation_offsets'][2]) + t_off = shape_config['tbjs_key_translation_offsets'][2] + shape = helpers.translate(shape, (t_off[0], t_off[1]+shape_config['tbjs_key_diameter']/2, t_off[2])) + shape = helpers.rotate(shape, [0,0,-180]) shape = tbjs_place(shape) - # shape = rotate(shape, [25, -11, 0]) - # shape = translate(shape, thumborigin()) - # shape = translate(shape, [-40, -50, -16]) + # shape = helpers.rotate(shape, [25, -11, 0]) + # shape = helpers.translate(shape, thumborigin()) + # shape = helpers.translate(shape, [-40, -50, -16]) return shape def tbjs_thumb_bl_place(shape): debugprint('thumb_bl_place()') - shape = rotate(shape, [0, 0, 180]) - shape = rotate(shape, tbjs_key_rotation_offsets[3]) - t_off = tbjs_key_translation_offsets[3] - shape = translate(shape, (t_off[0], t_off[1]+tbjs_key_diameter/2, t_off[2])) - shape = rotate(shape, [0,0,-230]) + shape = helpers.rotate(shape, [0, 0, 180]) + shape = helpers.rotate(shape, shape_config['tbjs_key_rotation_offsets'][3]) + t_off = shape_config['tbjs_key_translation_offsets'][3] + shape = helpers.translate(shape, (t_off[0], t_off[1]+shape_config['tbjs_key_diameter']/2, t_off[2])) + shape = helpers.rotate(shape, [0,0,-230]) shape = tbjs_place(shape) - # shape = rotate(shape, [25, 0, -45]) - # shape = translate(shape, thumborigin()) - # shape = translate(shape, [-63, -41, -18]) + # shape = helpers.rotate(shape, [25, 0, -45]) + # shape = helpers.translate(shape, thumborigin()) + # shape = helpers.translate(shape, [-63, -41, -18]) return shape # def tbjs_thumb_tlold_place(shape): # debugprint('thumb_tl_place()') -# shape = rotate(shape, [7.5, -10, 10]) -# shape = translate(shape, thumborigin()) -# shape = translate(shape, [-32.5, -14.5, -4]) +# shape = helpers.rotate(shape, [7.5, -10, 10]) +# shape = helpers.translate(shape, thumborigin()) +# shape = helpers.translate(shape, [-32.5, -14.5, -4]) # return shape # # # def tbjs_thumb_mlold_place(shape): # debugprint('thumb_ml_place()') -# shape = rotate(shape, [6, -34, 40]) -# shape = translate(shape, thumborigin()) -# shape = translate(shape, [-51, -25, -12]) +# shape = helpers.rotate(shape, [6, -34, 40]) +# shape = helpers.translate(shape, thumborigin()) +# shape = helpers.translate(shape, [-51, -25, -12]) # return shape def tbjs_thumb_1x_layout(shape): - return union([ - tbjs_thumb_tl_place(rotate(shape, [0, 0, thumb_plate_tr_rotation])), - # tbjs_thumb_tlold_place(rotate(shape, [0, 0, thumb_plate_tl_rotation])), - # tbjs_thumb_mlold_place(rotate(shape, [0, 0, thumb_plate_ml_rotation])), - tbjs_thumb_mr_place(rotate(shape, [0, 0, thumb_plate_mr_rotation])), - tbjs_thumb_bl_place(rotate(shape, [0, 0, thumb_plate_bl_rotation])), - tbjs_thumb_br_place(rotate(shape, [0, 0, thumb_plate_br_rotation])), + return helpers.union([ + tbjs_thumb_tl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tr_rotation']])), + # tbjs_thumb_tlold_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tl_rotation']])), + # tbjs_thumb_mlold_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_ml_rotation']])), + tbjs_thumb_mr_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_mr_rotation']])), + tbjs_thumb_bl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_bl_rotation']])), + tbjs_thumb_br_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_br_rotation']])), ]) def tbjs_thumb_fx_layout(shape): - return union([ - # tbjs_thumb_tl_place(rotate(shape, [0, 0, thumb_plate_tr_rotation])), - # tbjs_thumb_tlold_place(rotate(shape, [0, 0, thumb_plate_tl_rotation])), - # tbjs_thumb_mlold_place(rotate(shape, [0, 0, thumb_plate_ml_rotation])), - # tbjs_thumb_mr_place(rotate(shape, [0, 0, thumb_plate_mr_rotation])), - # tbjs_thumb_bl_place(rotate(shape, [0, 0, thumb_plate_bl_rotation])), - # tbjs_thumb_br_place(rotate(shape, [0, 0, thumb_plate_br_rotation])), + return helpers.union([ + # tbjs_thumb_tl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tr_rotation']])), + # tbjs_thumb_tlold_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tl_rotation']])), + # tbjs_thumb_mlold_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_ml_rotation']])), + # tbjs_thumb_mr_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_mr_rotation']])), + # tbjs_thumb_bl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_bl_rotation']])), + # tbjs_thumb_br_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_br_rotation']])), ]) def trackball_layout(shape): - return union([ + return helpers.union([ # Relocating positioning to individual parts due to complexity. - # tbjs_place(rotate(shape, [0, 0, trackball_rotation])), + # tbjs_place(helpers.rotate(shape, [0, 0, trackball_rotation])), tbjs_place(shape), ]) def tbjs_thumbcaps(): t1 = tbjs_thumb_1x_layout(sa_cap(1)) - # t1.add(tbjs_thumb_15x_layout(rotate(sa_cap(1), [0, 0, rad2deg(pi / 2)]))) + # t1.helpers.add(tbjs_thumb_15x_layout(helpers.rotate(sa_cap(1), [0, 0, rad2deg(pi / 2)]))) return t1 def tbjs_thumb(side="right"): - shape = tbjs_thumb_fx_layout(rotate(single_plate(side=side), [0.0, 0.0, -90])) - shape = union([shape, tbjs_thumb_fx_layout(double_plate())]) - shape = union([shape, tbjs_thumb_1x_layout(single_plate(side=side))]) + shape = tbjs_thumb_fx_layout(helpers.rotate(single_plate(side=side), [0.0, 0.0, -90])) + shape = helpers.union([shape, tbjs_thumb_fx_layout(double_plate())]) + shape = helpers.union([shape, tbjs_thumb_1x_layout(single_plate(side=side))]) - # shape = union([shape, trackball_layout(trackball_socket())]) + # shape = helpers.union([shape, trackball_layout(trackball_socket())]) # shape = tbjs_thumb_1x_layout(single_plate(side=side)) return shape def tbjs_thumb_post_tr(): debugprint('thumb_post_tr()') - return translate(web_post(), - [(mount_width / 2) - post_adj, ((mount_height/2) + adjustable_plate_size(trackball_Usize)) - post_adj, 0] + return helpers.translate(web_post(), + [(shape_config['mount_width'] / 2) - shape_config['post_adj'], ((shape_config['mount_height']/2) + adjustable_plate_size(shape_config['trackball_Usize'])) - shape_config['post_adj'], 0] ) def tbjs_thumb_post_tl(): debugprint('thumb_post_tl()') - return translate(web_post(), - [-(mount_width / 2) + post_adj, ((mount_height/2) + adjustable_plate_size(trackball_Usize)) - post_adj, 0] + return helpers.translate(web_post(), + [-(shape_config['mount_width'] / 2) + shape_config['post_adj'], ((shape_config['mount_height']/2) + adjustable_plate_size(shape_config['trackball_Usize'])) - shape_config['post_adj'], 0] ) def tbjs_thumb_post_bl(): debugprint('thumb_post_bl()') - return translate(web_post(), - [-(mount_width / 2) + post_adj, -((mount_height/2) + adjustable_plate_size(trackball_Usize)) + post_adj, 0] + return helpers.translate(web_post(), + [-(shape_config['mount_width'] / 2) + shape_config['post_adj'], -((shape_config['mount_height']/2) + adjustable_plate_size(shape_config['trackball_Usize'])) + shape_config['post_adj'], 0] ) def tbjs_thumb_post_br(): debugprint('thumb_post_br()') - return translate(web_post(), - [(mount_width / 2) - post_adj, -((mount_height/2) + adjustable_plate_size(trackball_Usize)) + post_adj, 0] + return helpers.translate(web_post(), + [(shape_config['mount_width'] / 2) - shape_config['post_adj'], -((shape_config['mount_height']/2) + adjustable_plate_size(shape_config['trackball_Usize'])) + shape_config['post_adj'], 0] ) def tbjs_post_r(): debugprint('tbjs_post_r()') - radius = ball_diameter/2 + ball_wall_thickness + ball_gap - return translate(web_post(), - [1.0*(radius - post_adj), 0.0*(radius - post_adj), 0] + radius = shape_config['ball_diameter']/2 + shape_config['ball_wall_thickness'] + shape_config['ball_gap'] + return helpers.translate(web_post(), + [1.0*(radius - shape_config['post_adj']), 0.0*(radius - shape_config['post_adj']), 0] ) def tbjs_post_tr(): debugprint('tbjs_post_tr()') - radius = ball_diameter/2+ball_wall_thickness + ball_gap - return translate(web_post(), - [0.5*(radius - post_adj), 0.866*(radius - post_adj), 0] + radius = shape_config['ball_diameter']/2+shape_config['ball_wall_thickness'] + shape_config['ball_gap'] + return helpers.translate(web_post(), + [0.5*(radius - shape_config['post_adj']), 0.866*(radius - shape_config['post_adj']), 0] ) def tbjs_post_tl(): debugprint('tbjs_post_tl()') - radius = ball_diameter/2+ball_wall_thickness + ball_gap - return translate(web_post(), - [-0.5*(radius - post_adj), 0.866*(radius - post_adj), 0] + radius = shape_config['ball_diameter']/2+shape_config['ball_wall_thickness'] + shape_config['ball_gap'] + return helpers.translate(web_post(), + [-0.5*(radius - shape_config['post_adj']), 0.866*(radius - shape_config['post_adj']), 0] ) def tbjs_post_l(): debugprint('tbjs_post_l()') - radius = ball_diameter/2+ball_wall_thickness + ball_gap - return translate(web_post(), - [-1.0*(radius - post_adj), 0.0*(radius - post_adj), 0] + radius = shape_config['ball_diameter']/2+shape_config['ball_wall_thickness'] + shape_config['ball_gap'] + return helpers.translate(web_post(), + [-1.0*(radius - shape_config['post_adj']), 0.0*(radius - shape_config['post_adj']), 0] ) def tbjs_post_bl(): debugprint('tbjs_post_bl()') - radius = ball_diameter/2+ball_wall_thickness + ball_gap - return translate(web_post(), - [-0.5*(radius - post_adj), -0.866*(radius - post_adj), 0] + radius = shape_config['ball_diameter']/2+shape_config['ball_wall_thickness'] + shape_config['ball_gap'] + return helpers.translate(web_post(), + [-0.5*(radius - shape_config['post_adj']), -0.866*(radius - shape_config['post_adj']), 0] ) def tbjs_post_br(): debugprint('tbjs_post_br()') - radius = ball_diameter/2+ball_wall_thickness + ball_gap - return translate(web_post(), - [0.5*(radius - post_adj), -0.866*(radius - post_adj), 0] + radius = shape_config['ball_diameter']/2+shape_config['ball_wall_thickness'] + shape_config['ball_gap'] + return helpers.translate(web_post(), + [0.5*(radius - shape_config['post_adj']), -0.866*(radius - shape_config['post_adj']), 0] ) @@ -1983,7 +1984,7 @@ def tbjs_thumb_connectors(): # bottom 2 to tb hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ tbjs_place(tbjs_post_l()), tbjs_thumb_bl_place(web_post_tl()), @@ -2002,7 +2003,7 @@ def tbjs_thumb_connectors(): tbjs_place(tbjs_post_r()), tbjs_thumb_tl_place(web_post_bl()), tbjs_place(tbjs_post_tr()), - key_place(web_post_bl(), 0, cornerrow), + key_place(web_post_bl(), 0, shape_config['cornerrow']), tbjs_place(tbjs_post_tl()), ] ) @@ -2010,7 +2011,7 @@ def tbjs_thumb_connectors(): # bottom left hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ tbjs_thumb_bl_place(web_post_tr()), tbjs_thumb_br_place(web_post_tl()), @@ -2022,7 +2023,7 @@ def tbjs_thumb_connectors(): # bottom right hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ tbjs_thumb_br_place(web_post_tr()), tbjs_thumb_mr_place(web_post_br()), @@ -2033,7 +2034,7 @@ def tbjs_thumb_connectors(): ) # top right hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ tbjs_thumb_mr_place(web_post_bl()), tbjs_thumb_tl_place(web_post_br()), @@ -2044,30 +2045,30 @@ def tbjs_thumb_connectors(): ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_br(), 1, cornerrow), - key_place(web_post_tl(), 2, lastrow), - key_place(web_post_bl(), 2, cornerrow), - key_place(web_post_tr(), 2, lastrow), - key_place(web_post_br(), 2, cornerrow), - key_place(web_post_bl(), 3, cornerrow), + key_place(web_post_br(), 1, shape_config['cornerrow']), + key_place(web_post_tl(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 2, shape_config['cornerrow']), + key_place(web_post_tr(), 2, shape_config['lastrow']), + key_place(web_post_br(), 2, shape_config['cornerrow']), + key_place(web_post_bl(), 3, shape_config['cornerrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_br(), 3, lastrow), - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_bl(), 4, cornerrow), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_br(), 3, shape_config['lastrow']), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_bl(), 4, shape_config['cornerrow']), ] ) ) - return union(hulls) + return helpers.union(hulls) @@ -2080,35 +2081,35 @@ def tbjs_thumb_connectors(): # single_plate = the switch shape def tbcj_thumb_tr_place(shape): - shape = rotate(shape, [10, -15, 10]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-12, -16, 3]) + shape = helpers.rotate(shape, [10, -15, 10]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-12, -16, 3]) return shape def tbcj_thumb_tl_place(shape): - shape = rotate(shape, [7.5, -18, 10]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-32.5, -14.5, -2.5]) + shape = helpers.rotate(shape, [7.5, -18, 10]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-32.5, -14.5, -2.5]) return shape def tbcj_thumb_ml_place(shape): - shape = rotate(shape, [6, -34, 40]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-51, -25, -12]) + shape = helpers.rotate(shape, [6, -34, 40]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-51, -25, -12]) return shape def tbcj_thumb_bl_place(shape): - shape = rotate(shape, [-4, -35, 52]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-56.3, -43.3, -23.5]) + shape = helpers.rotate(shape, [-4, -35, 52]) + shape = helpers.translate(shape, thumborigin()) + shape = helpers.translate(shape, [-56.3, -43.3, -23.5]) return shape def tbcj_thumb_layout(shape): - return union([ - tbcj_thumb_tr_place(rotate(shape, [0, 0, thumb_plate_tr_rotation])), - tbcj_thumb_tl_place(rotate(shape, [0, 0, thumb_plate_tl_rotation])), - tbcj_thumb_ml_place(rotate(shape, [0, 0, thumb_plate_ml_rotation])), - tbcj_thumb_bl_place(rotate(shape, [0, 0, thumb_plate_bl_rotation])), + return helpers.union([ + tbcj_thumb_tr_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tr_rotation']])), + tbcj_thumb_tl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_tl_rotation']])), + tbcj_thumb_ml_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_ml_rotation']])), + tbcj_thumb_bl_place(helpers.rotate(shape, [0, 0, shape_config['thumb_plate_bl_rotation']])), ]) @@ -2118,7 +2119,7 @@ def tbcj_thumb_layout(shape): # points_x = [1, 2, 2, 1, -1, -2, -2, -1] # points_y = [2, 1, -1, -2, -2, -1, 1, 2] # -# return translate(shape, (points_x[i] * radius / 2, points_y[i] * radius / 2, 0)) +# return helpers.translate(shape, (points_x[i] * radius / 2, points_y[i] * radius / 2, 0)) def oct_corner(i, diameter, shape): radius = diameter / 2 @@ -2130,42 +2131,42 @@ def oct_corner(i, diameter, shape): points_x = [m, r, r, m, -m, -r, -r, -m] points_y = [r, m, -m, -r, -r, -m, m, r] - return translate(shape, (points_x[i], points_y[i], 0)) + return helpers.translate(shape, (points_x[i], points_y[i], 0)) def tbcj_edge_post(i): - shape = box(post_size, post_size, tbcj_thickness) - shape = oct_corner(i, tbcj_outer_diameter, shape) + shape = helpers.box(shape_config['post_size'], shape_config['post_size'], shape_config['tbcj_thickness']) + shape = oct_corner(i, shape_config['tbcj_outer_diameter'], shape) return shape def tbcj_web_post(i): - shape = box(post_size, post_size, tbcj_thickness) - shape = oct_corner(i, tbcj_outer_diameter, shape) + shape = helpers.box(shape_config['post_size'], shape_config['post_size'], shape_config['tbcj_thickness']) + shape = oct_corner(i, shape_config['tbcj_outer_diameter'], shape) return shape def tbcj_holder(): - center = box(post_size, post_size, tbcj_thickness) + center = helpers.box(shape_config['post_size'], shape_config['post_size'], shape_config['tbcj_thickness']) shape = [] for i in range(8): - shape_ = hull_from_shapes([ + shape_ = helpers.hull_from_shapes([ center, tbcj_edge_post(i), tbcj_edge_post(i + 1), ]) shape.append(shape_) - shape = union(shape) + shape = helpers.union(shape) - shape = difference( + shape = helpers.difference( shape, - [cylinder(tbcj_inner_diameter/2, tbcj_thickness + 0.1)] + [helpers.cylinder(shape_config['tbcj_inner_diameter']/2, shape_config['tbcj_thickness'] + 0.1)] ) return shape def tbcj_thumb_position_rotation(): # loc = np.array([-15, -60, -12]) + thumborigin() - # shape = translate(shape, loc) - # shape = rotate(shape, (0,0,0)) + # shape = helpers.translate(shape, loc) + # shape = helpers.rotate(shape, (0,0,0)) pos = np.array([-15, -60, -12]) + thumborigin() rot = (0,0,0) return pos, rot @@ -2173,14 +2174,14 @@ def tbcj_thumb_position_rotation(): def tbcj_place(shape): loc = np.array([-15, -60, -12]) + thumborigin() - shape = translate(shape, loc) - shape = rotate(shape, (0,0,0)) + shape = helpers.translate(shape, loc) + shape = helpers.rotate(shape, (0,0,0)) return shape def tbcj_thumb(side="right"): t = tbcj_thumb_layout(single_plate(side=side)) tb = tbcj_place(tbcj_holder()) - return union([t, tb]) + return helpers.union([t, tb]) def tbcj_thumbcaps(): t = tbcj_thumb_layout(sa_cap(1)) @@ -2189,26 +2190,26 @@ def tbcj_thumbcaps(): # TODO: VERIFY THEY CAN BE DELETED. THEY LOOK LIKE REPLICATES. # def thumb_post_tr(): -# return translate(web_post(), -# [(mount_width / 2) - post_adj, ((mount_height/2) + double_plate_height) - post_adj, 0] +# return helpers.translate(web_post(), +# [(shape_config['mount_width'] / 2) - shape_config['post_adj'], ((shape_config['mount_height']/2) + shape_config['double_plate_height']) - shape_config['post_adj'], 0] # ) # # # def thumb_post_tl(): -# return translate(web_post(), -# [-(mount_width / 2) + post_adj, ((mount_height/2) + double_plate_height) - post_adj, 0] +# return helpers.translate(web_post(), +# [-(shape_config['mount_width'] / 2) + shape_config['post_adj'], ((shape_config['mount_height']/2) + shape_config['double_plate_height']) - shape_config['post_adj'], 0] # ) # # # def thumb_post_bl(): -# return translate(web_post(), -# [-(mount_width / 2) + post_adj, -((mount_height/2) + double_plate_height) + post_adj, 0] +# return helpers.translate(web_post(), +# [-(shape_config['mount_width'] / 2) + shape_config['post_adj'], -((shape_config['mount_height']/2) + shape_config['double_plate_height']) + shape_config['post_adj'], 0] # ) # # # def thumb_post_br(): -# return translate(web_post(), -# [(mount_width / 2) - post_adj, -((mount_height/2) + double_plate_height) + post_adj, 0] +# return helpers.translate(web_post(), +# [(shape_config['mount_width'] / 2) - shape_config['post_adj'], -((shape_config['mount_height']/2) + shape_config['double_plate_height']) + shape_config['post_adj'], 0] # ) def tbcj_thumb_connectors(): @@ -2216,7 +2217,7 @@ def tbcj_thumb_connectors(): # Top two hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ tbcj_thumb_tl_place(web_post_tr()), tbcj_thumb_tl_place(web_post_br()), @@ -2228,7 +2229,7 @@ def tbcj_thumb_connectors(): # centers of the bottom four hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ tbcj_thumb_bl_place(web_post_tr()), tbcj_thumb_bl_place(web_post_br()), @@ -2241,7 +2242,7 @@ def tbcj_thumb_connectors(): # top two to the middle two, starting on the left hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ tbcj_thumb_tl_place(web_post_tl()), tbcj_thumb_ml_place(web_post_tr()), @@ -2255,59 +2256,59 @@ def tbcj_thumb_connectors(): ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ tbcj_thumb_tl_place(web_post_tl()), - key_place(web_post_bl(), 0, cornerrow), + key_place(web_post_bl(), 0, shape_config['cornerrow']), tbcj_thumb_tl_place(web_post_tr()), - key_place(web_post_br(), 0, cornerrow), + key_place(web_post_br(), 0, shape_config['cornerrow']), tbcj_thumb_tr_place(web_post_tl()), - key_place(web_post_bl(), 1, cornerrow), + key_place(web_post_bl(), 1, shape_config['cornerrow']), tbcj_thumb_tr_place(web_post_tr()), - key_place(web_post_br(), 1, cornerrow), - key_place(web_post_tl(), 2, lastrow), - key_place(web_post_bl(), 2, lastrow), + key_place(web_post_br(), 1, shape_config['cornerrow']), + key_place(web_post_tl(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 2, shape_config['lastrow']), tbcj_thumb_tr_place(web_post_tr()), - key_place(web_post_bl(), 2, lastrow), + key_place(web_post_bl(), 2, shape_config['lastrow']), tbcj_thumb_tr_place(web_post_br()), - key_place(web_post_br(), 2, lastrow), - key_place(web_post_bl(), 3, lastrow), - key_place(web_post_tr(), 2, lastrow), - key_place(web_post_tl(), 3, lastrow), - key_place(web_post_bl(), 3, cornerrow), - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_br(), 3, cornerrow), - key_place(web_post_bl(), 4, cornerrow), + key_place(web_post_br(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 3, shape_config['lastrow']), + key_place(web_post_tr(), 2, shape_config['lastrow']), + key_place(web_post_tl(), 3, shape_config['lastrow']), + key_place(web_post_bl(), 3, shape_config['cornerrow']), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_br(), 3, shape_config['cornerrow']), + key_place(web_post_bl(), 4, shape_config['cornerrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_br(), 1, cornerrow), - key_place(web_post_tl(), 2, lastrow), - key_place(web_post_bl(), 2, cornerrow), - key_place(web_post_tr(), 2, lastrow), - key_place(web_post_br(), 2, cornerrow), - key_place(web_post_bl(), 3, cornerrow), + key_place(web_post_br(), 1, shape_config['cornerrow']), + key_place(web_post_tl(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 2, shape_config['cornerrow']), + key_place(web_post_tr(), 2, shape_config['lastrow']), + key_place(web_post_br(), 2, shape_config['cornerrow']), + key_place(web_post_bl(), 3, shape_config['cornerrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_br(), 3, lastrow), - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_bl(), 4, cornerrow), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_br(), 3, shape_config['lastrow']), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_bl(), 4, shape_config['cornerrow']), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ tbcj_place(tbcj_web_post(4)), tbcj_thumb_bl_place(web_post_bl()), @@ -2319,7 +2320,7 @@ def tbcj_thumb_connectors(): ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ tbcj_thumb_bl_place(web_post_br()), tbcj_place(tbcj_web_post(6)), @@ -2329,7 +2330,7 @@ def tbcj_thumb_connectors(): ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ tbcj_thumb_ml_place(web_post_bl()), tbcj_place(tbcj_web_post(6)), @@ -2340,7 +2341,7 @@ def tbcj_thumb_connectors(): ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ tbcj_place(tbcj_web_post(6)), tbcj_thumb_tr_place(web_post_bl()), @@ -2348,12 +2349,12 @@ def tbcj_thumb_connectors(): tbcj_thumb_tr_place(web_post_br()), tbcj_place(tbcj_web_post(0)), tbcj_thumb_tr_place(web_post_br()), - key_place(web_post_bl(), 3, lastrow), + key_place(web_post_bl(), 3, shape_config['lastrow']), ] ) ) - return union(hulls) + return helpers.union(hulls) @@ -2364,63 +2365,63 @@ def tbcj_thumb_connectors(): def left_key_position(row, direction, low_corner=False, side='right'): debugprint("left_key_position()") pos = np.array( - key_position([-mount_width * 0.5, direction * mount_height * 0.5, 0], 0, row) + key_position([-shape_config['mount_width'] * 0.5, direction * shape_config['mount_height'] * 0.5, 0], 0, row) ) - if trackball_in_wall and (side == ball_side or ball_side == 'both'): + if shape_config['trackball_in_wall'] and (side == shape_config['ball_side'] or shape_config['ball_side'] == 'both'): if low_corner: - y_offset = tbiw_left_wall_lower_y_offset - z_offset = tbiw_left_wall_lower_z_offset + y_offset = shape_config['tbiw_left_wall_lower_y_offset'] + z_offset = shape_config['tbiw_left_wall_lower_z_offset'] else: y_offset = 0.0 z_offset = 0.0 return list(pos - np.array([ - tbiw_left_wall_x_offset_override, + shape_config['tbiw_left_wall_x_offset_override'], -y_offset, - tbiw_left_wall_z_offset_override + z_offset + shape_config['tbiw_left_wall_z_offset_override'] + z_offset ])) if low_corner: - y_offset = left_wall_lower_y_offset - z_offset = left_wall_lower_z_offset + y_offset = shape_config['left_wall_lower_y_offset'] + z_offset = shape_config['left_wall_lower_z_offset'] else: y_offset = 0.0 z_offset = 0.0 - return list(pos - np.array([left_wall_x_offset, -y_offset, left_wall_z_offset + z_offset])) + return list(pos - np.array([shape_config['left_wall_x_offset'], -y_offset, shape_config['left_wall_z_offset'] + z_offset])) def left_key_place(shape, row, direction, low_corner=False, side='right'): debugprint("left_key_place()") pos = left_key_position(row, direction, low_corner=low_corner, side=side) - return translate(shape, pos) + return helpers.translate(shape, pos) def wall_locate1(dx, dy): debugprint("wall_locate1()") - return [dx * wall_thickness, dy * wall_thickness, -1] + return [dx * shape_config['wall_thickness'], dy * shape_config['wall_thickness'], -1] def wall_locate2(dx, dy): debugprint("wall_locate2()") - return [dx * wall_x_offset, dy * wall_y_offset, -wall_z_offset] + return [dx * shape_config['wall_x_offset'], dy * shape_config['wall_y_offset'], -shape_config['wall_z_offset']] def wall_locate3(dx, dy, back=False): debugprint("wall_locate3()") if back: return [ - dx * (wall_x_offset + wall_base_x_thickness), - dy * (wall_y_offset + wall_base_back_thickness), - -wall_z_offset, + dx * (shape_config['wall_x_offset'] + shape_config['wall_base_x_thickness']), + dy * (shape_config['wall_y_offset'] + shape_config['wall_base_back_thickness']), + -shape_config['wall_z_offset'], ] else: return [ - dx * (wall_x_offset + wall_base_x_thickness), - dy * (wall_y_offset + wall_base_y_thickness), - -wall_z_offset, + dx * (shape_config['wall_x_offset'] + shape_config['wall_base_x_thickness']), + dy * (shape_config['wall_y_offset'] + shape_config['wall_base_y_thickness']), + -shape_config['wall_z_offset'], ] # return [ # dx * (wall_xy_offset + wall_thickness), @@ -2434,24 +2435,24 @@ def wall_brace(place1, dx1, dy1, post1, place2, dx2, dy2, post2, back=False): hulls = [] hulls.append(place1(post1)) - hulls.append(place1(translate(post1, wall_locate1(dx1, dy1)))) - hulls.append(place1(translate(post1, wall_locate2(dx1, dy1)))) - hulls.append(place1(translate(post1, wall_locate3(dx1, dy1, back)))) + hulls.append(place1(helpers.translate(post1, wall_locate1(dx1, dy1)))) + hulls.append(place1(helpers.translate(post1, wall_locate2(dx1, dy1)))) + hulls.append(place1(helpers.translate(post1, wall_locate3(dx1, dy1, back)))) hulls.append(place2(post2)) - hulls.append(place2(translate(post2, wall_locate1(dx2, dy2)))) - hulls.append(place2(translate(post2, wall_locate2(dx2, dy2)))) - hulls.append(place2(translate(post2, wall_locate3(dx2, dy2, back)))) - shape1 = hull_from_shapes(hulls) + hulls.append(place2(helpers.translate(post2, wall_locate1(dx2, dy2)))) + hulls.append(place2(helpers.translate(post2, wall_locate2(dx2, dy2)))) + hulls.append(place2(helpers.translate(post2, wall_locate3(dx2, dy2, back)))) + shape1 = helpers.hull_from_shapes(hulls) hulls = [] - hulls.append(place1(translate(post1, wall_locate2(dx1, dy1)))) - hulls.append(place1(translate(post1, wall_locate3(dx1, dy1, back)))) - hulls.append(place2(translate(post2, wall_locate2(dx2, dy2)))) - hulls.append(place2(translate(post2, wall_locate3(dx2, dy2, back)))) - shape2 = bottom_hull(hulls) + hulls.append(place1(helpers.translate(post1, wall_locate2(dx1, dy1)))) + hulls.append(place1(helpers.translate(post1, wall_locate3(dx1, dy1, back)))) + hulls.append(place2(helpers.translate(post2, wall_locate2(dx2, dy2)))) + hulls.append(place2(helpers.translate(post2, wall_locate3(dx2, dy2, back)))) + shape2 = helpers.bottom_hull(hulls) - return union([shape1, shape2]) + return helpers.union([shape1, shape2]) # return shape1 @@ -2473,15 +2474,15 @@ def key_wall_brace(x1, y1, dx1, dy1, post1, x2, y2, dx2, dy2, post2, back=False) def back_wall(): print("back_wall()") x = 0 - shape = union([key_wall_brace(x, 0, 0, 1, web_post_tl(), x, 0, 0, 1, web_post_tr(), back=True)]) - for i in range(ncols - 1): + shape = helpers.union([key_wall_brace(x, 0, 0, 1, web_post_tl(), x, 0, 0, 1, web_post_tr(), back=True)]) + for i in range(shape_config['ncols'] - 1): x = i + 1 - shape = union([shape, key_wall_brace(x, 0, 0, 1, web_post_tl(), x, 0, 0, 1, web_post_tr(), back=True)]) - shape = union([shape, key_wall_brace( + shape = helpers.union([shape, key_wall_brace(x, 0, 0, 1, web_post_tl(), x, 0, 0, 1, web_post_tr(), back=True)]) + shape = helpers.union([shape, key_wall_brace( x, 0, 0, 1, web_post_tl(), x - 1, 0, 0, 1, web_post_tr(), back=True )]) - shape = union([shape, key_wall_brace( - lastcol, 0, 0, 1, web_post_tr(), lastcol, 0, 1, 0, web_post_tr(), back=True + shape = helpers.union([shape, key_wall_brace( + shape_config['lastcol'], 0, 0, 1, web_post_tr(),shape_config['lastcol'], 0, 1, 0, web_post_tr(), back=True )]) return shape @@ -2489,99 +2490,99 @@ def back_wall(): def right_wall(): print("right_wall()") y = 0 - shape = union([ + shape = helpers.union([ key_wall_brace( - lastcol, y, 1, 0, web_post_tr(), lastcol, y, 1, 0, web_post_br() + shape_config['lastcol'], y, 1, 0, web_post_tr(),shape_config['lastcol'], y, 1, 0, web_post_br() ) ]) - for i in range(lastrow - 1): + for i in range(shape_config['lastrow'] - 1): y = i + 1 - shape = union([shape, key_wall_brace( - lastcol, y - 1, 1, 0, web_post_br(), lastcol, y, 1, 0, web_post_tr() + shape = helpers.union([shape, key_wall_brace( + shape_config['lastcol'], y - 1, 1, 0, web_post_br(),shape_config['lastcol'], y, 1, 0, web_post_tr() )]) - shape = union([shape, key_wall_brace( - lastcol, y, 1, 0, web_post_tr(), lastcol, y, 1, 0, web_post_br() + shape = helpers.union([shape, key_wall_brace( + shape_config['lastcol'], y, 1, 0, web_post_tr(),shape_config['lastcol'], y, 1, 0, web_post_br() )]) #STRANGE PARTIAL OFFSET - shape = union([ + shape = helpers.union([ shape, - key_wall_brace(lastcol, cornerrow, 0, -1, web_post_br(), lastcol, cornerrow, 1, 0, web_post_br()) + key_wall_brace(shape_config['lastcol'], shape_config['cornerrow'], 0, -1, web_post_br(),shape_config['lastcol'], shape_config['cornerrow'], 1, 0, web_post_br()) ]) return shape def left_wall(side='right'): print('left_wall()') - shape = union([wall_brace( + shape = helpers.union([wall_brace( (lambda sh: key_place(sh, 0, 0)), 0, 1, web_post_tl(), (lambda sh: left_key_place(sh, 0, 1, side=side)), 0, 1, web_post(), )]) - shape = union([shape, wall_brace( + shape = helpers.union([shape, wall_brace( (lambda sh: left_key_place(sh, 0, 1, side=side)), 0, 1, web_post(), (lambda sh: left_key_place(sh, 0, 1, side=side)), -1, 0, web_post(), )]) - for i in range(lastrow): + for i in range(shape_config['lastrow']): y = i - low = (y == (lastrow-1)) + low = (y == (shape_config['lastrow']-1)) temp_shape1 = wall_brace( (lambda sh: left_key_place(sh, y, 1, side=side)), -1, 0, web_post(), (lambda sh: left_key_place(sh, y, -1, low_corner=low, side=side)), -1, 0, web_post(), ) - temp_shape2 = hull_from_shapes(( + temp_shape2 = helpers.hull_from_shapes(( key_place(web_post_tl(), 0, y), key_place(web_post_bl(), 0, y), left_key_place(web_post(), y, 1, side=side), left_key_place(web_post(), y, -1, low_corner=low, side=side), )) - shape = union([shape, temp_shape1]) - shape = union([shape, temp_shape2]) + shape = helpers.union([shape, temp_shape1]) + shape = helpers.union([shape, temp_shape2]) - for i in range(lastrow - 1): + for i in range(shape_config['lastrow'] - 1): y = i + 1 - low = (y == (lastrow-1)) + low = (y == (shape_config['lastrow']-1)) temp_shape1 = wall_brace( (lambda sh: left_key_place(sh, y - 1, -1, side=side)), -1, 0, web_post(), (lambda sh: left_key_place(sh, y, 1, side=side)), -1, 0, web_post(), ) - temp_shape2 = hull_from_shapes(( + temp_shape2 = helpers.hull_from_shapes(( key_place(web_post_tl(), 0, y), key_place(web_post_bl(), 0, y - 1), left_key_place(web_post(), y, 1, side=side), left_key_place(web_post(), y - 1, -1, side=side), )) - shape = union([shape, temp_shape1]) - shape = union([shape, temp_shape2]) + shape = helpers.union([shape, temp_shape1]) + shape = helpers.union([shape, temp_shape2]) return shape def front_wall(): print('front_wall()') - shape = union([ + shape = helpers.union([ key_wall_brace( - lastcol, 0, 0, 1, web_post_tr(), lastcol, 0, 1, 0, web_post_tr() + shape_config['lastcol'], 0, 0, 1, web_post_tr(),shape_config['lastcol'], 0, 1, 0, web_post_tr() ) ]) - shape = union([shape,key_wall_brace( - 3, lastrow, 0, -1, web_post_bl(), 3, lastrow, 0.5, -1, web_post_br() + shape = helpers.union([shape,key_wall_brace( + 3, shape_config['lastrow'], 0, -1, web_post_bl(), 3, shape_config['lastrow'], 0.5, -1, web_post_br() )]) - shape = union([shape,key_wall_brace( - 3, lastrow, 0.5, -1, web_post_br(), 4, cornerrow, 1, -1, web_post_bl() + shape = helpers.union([shape,key_wall_brace( + 3, shape_config['lastrow'], 0.5, -1, web_post_br(), 4, shape_config['cornerrow'], 1, -1, web_post_bl() )]) - for i in range(ncols - 4): + for i in range(shape_config['ncols'] - 4): x = i + 4 - shape = union([shape,key_wall_brace( - x, cornerrow, 0, -1, web_post_bl(), x, cornerrow, 0, -1, web_post_br() + shape = helpers.union([shape,key_wall_brace( + x, shape_config['cornerrow'], 0, -1, web_post_bl(), x, shape_config['cornerrow'], 0, -1, web_post_br() )]) - for i in range(ncols - 5): + for i in range(shape_config['ncols'] - 5): x = i + 5 - shape = union([shape, key_wall_brace( - x, cornerrow, 0, -1, web_post_bl(), x - 1, cornerrow, 0, -1, web_post_br() + shape = helpers.union([shape, key_wall_brace( + x, shape_config['cornerrow'], 0, -1, web_post_bl(), x - 1, shape_config['cornerrow'], 0, -1, web_post_br() )]) return shape @@ -2589,7 +2590,7 @@ def front_wall(): def thumb_walls(side='right', style_override=None): if style_override is None: - _thumb_style = thumb_style + _thumb_style = shape_config['thumb_style'] else: _thumb_style = style_override @@ -2601,20 +2602,20 @@ def thumb_walls(side='right', style_override=None): return carbonfet_thumb_walls() elif "TRACKBALL" in _thumb_style: - if (side == ball_side or ball_side == 'both'): + if (side == shape_config['ball_side'] or shape_config['ball_side'] == 'both'): if _thumb_style == "TRACKBALL_ORBYL": return tbjs_thumb_walls() - elif thumb_style == "TRACKBALL_CJ": + elif shape_config['thumb_style'] == "TRACKBALL_CJ": return tbcj_thumb_walls() else: - return thumb_walls(side, style_override=other_thumb) + return thumb_walls(side, style_override=shape_config['other_thumb']) else: return default_thumb_walls() def thumb_connection(side='right', style_override=None): if style_override is None: - _thumb_style = thumb_style + _thumb_style = shape_config['thumb_style'] else: _thumb_style = style_override @@ -2626,13 +2627,13 @@ def thumb_connection(side='right', style_override=None): return carbonfet_thumb_connection(side=side) elif "TRACKBALL" in _thumb_style: - if (side == ball_side or ball_side == 'both'): + if (side == shape_config['ball_side'] or shape_config['ball_side'] == 'both'): if _thumb_style == "TRACKBALL_ORBYL": return tbjs_thumb_connection(side=side) - elif thumb_style == "TRACKBALL_CJ": + elif shape_config['thumb_style'] == "TRACKBALL_CJ": return tbcj_thumb_connection(side=side) else: - return thumb_connection(side, style_override=other_thumb) + return thumb_connection(side, style_override=shape_config['other_thumb']) else: return default_thumb_connection(side=side) @@ -2640,27 +2641,27 @@ def thumb_connection(side='right', style_override=None): def default_thumb_walls(): print('thumb_walls()') # thumb, walls - if default_1U_cluster: - shape = union([wall_brace(default_thumb_mr_place, 0, -1, web_post_br(), default_thumb_tr_place, 0, -1, web_post_br())]) + if shape_config['default_1U_cluster']: + shape = helpers.union([wall_brace(default_thumb_mr_place, 0, -1, web_post_br(), default_thumb_tr_place, 0, -1, web_post_br())]) else: - shape = union([wall_brace(default_thumb_mr_place, 0, -1, web_post_br(), default_thumb_tr_place, 0, -1, thumb_post_br())]) - shape = union([shape, wall_brace(default_thumb_mr_place, 0, -1, web_post_br(), default_thumb_mr_place, 0, -1, web_post_bl())]) - shape = union([shape, wall_brace(default_thumb_br_place, 0, -1, web_post_br(), default_thumb_br_place, 0, -1, web_post_bl())]) - shape = union([shape, wall_brace(default_thumb_ml_place, -0.3, 1, web_post_tr(), default_thumb_ml_place, 0, 1, web_post_tl())]) - shape = union([shape, wall_brace(default_thumb_bl_place, 0, 1, web_post_tr(), default_thumb_bl_place, 0, 1, web_post_tl())]) - shape = union([shape, wall_brace(default_thumb_br_place, -1, 0, web_post_tl(), default_thumb_br_place, -1, 0, web_post_bl())]) - shape = union([shape, wall_brace(default_thumb_bl_place, -1, 0, web_post_tl(), default_thumb_bl_place, -1, 0, web_post_bl())]) + shape = helpers.union([wall_brace(default_thumb_mr_place, 0, -1, web_post_br(), default_thumb_tr_place, 0, -1, thumb_post_br())]) + shape = helpers.union([shape, wall_brace(default_thumb_mr_place, 0, -1, web_post_br(), default_thumb_mr_place, 0, -1, web_post_bl())]) + shape = helpers.union([shape, wall_brace(default_thumb_br_place, 0, -1, web_post_br(), default_thumb_br_place, 0, -1, web_post_bl())]) + shape = helpers.union([shape, wall_brace(default_thumb_ml_place, -0.3, 1, web_post_tr(), default_thumb_ml_place, 0, 1, web_post_tl())]) + shape = helpers.union([shape, wall_brace(default_thumb_bl_place, 0, 1, web_post_tr(), default_thumb_bl_place, 0, 1, web_post_tl())]) + shape = helpers.union([shape, wall_brace(default_thumb_br_place, -1, 0, web_post_tl(), default_thumb_br_place, -1, 0, web_post_bl())]) + shape = helpers.union([shape, wall_brace(default_thumb_bl_place, -1, 0, web_post_tl(), default_thumb_bl_place, -1, 0, web_post_bl())]) # thumb, corners - shape = union([shape, wall_brace(default_thumb_br_place, -1, 0, web_post_bl(), default_thumb_br_place, 0, -1, web_post_bl())]) - shape = union([shape, wall_brace(default_thumb_bl_place, -1, 0, web_post_tl(), default_thumb_bl_place, 0, 1, web_post_tl())]) + shape = helpers.union([shape, wall_brace(default_thumb_br_place, -1, 0, web_post_bl(), default_thumb_br_place, 0, -1, web_post_bl())]) + shape = helpers.union([shape, wall_brace(default_thumb_bl_place, -1, 0, web_post_tl(), default_thumb_bl_place, 0, 1, web_post_tl())]) # thumb, tweeners - shape = union([shape, wall_brace(default_thumb_mr_place, 0, -1, web_post_bl(), default_thumb_br_place, 0, -1, web_post_br())]) - shape = union([shape, wall_brace(default_thumb_ml_place, 0, 1, web_post_tl(), default_thumb_bl_place, 0, 1, web_post_tr())]) - shape = union([shape, wall_brace(default_thumb_bl_place, -1, 0, web_post_bl(), default_thumb_br_place, -1, 0, web_post_tl())]) - if default_1U_cluster: - shape = union([shape, wall_brace(default_thumb_tr_place, 0, -1, web_post_br(), (lambda sh: key_place(sh, 3, lastrow)), 0, -1, web_post_bl())]) + shape = helpers.union([shape, wall_brace(default_thumb_mr_place, 0, -1, web_post_bl(), default_thumb_br_place, 0, -1, web_post_br())]) + shape = helpers.union([shape, wall_brace(default_thumb_ml_place, 0, 1, web_post_tl(), default_thumb_bl_place, 0, 1, web_post_tr())]) + shape = helpers.union([shape, wall_brace(default_thumb_bl_place, -1, 0, web_post_bl(), default_thumb_br_place, -1, 0, web_post_tl())]) + if shape_config['default_1U_cluster']: + shape = helpers.union([shape, wall_brace(default_thumb_tr_place, 0, -1, web_post_br(), (lambda sh: key_place(sh, 3, shape_config['lastrow'])), 0, -1, web_post_bl())]) else: - shape = union([shape, wall_brace(default_thumb_tr_place, 0, -1, thumb_post_br(), (lambda sh: key_place(sh, 3, lastrow)), 0, -1, web_post_bl())]) + shape = helpers.union([shape, wall_brace(default_thumb_tr_place, 0, -1, thumb_post_br(), (lambda sh: key_place(sh, 3, shape_config['lastrow'])), 0, -1, web_post_bl())]) return shape @@ -2668,51 +2669,51 @@ def default_thumb_walls(): def default_thumb_connection(side='right'): print('thumb_connection()') # clunky bit on the top left thumb connection (normal connectors don't work well) - shape = union([bottom_hull( + shape = helpers.union([helpers.bottom_hull( [ - left_key_place(translate(web_post(), wall_locate2(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate3(-1, 0)), cornerrow, -1, low_corner=True, side=side), - default_thumb_ml_place(translate(web_post_tr(), wall_locate2(-0.3, 1))), - default_thumb_ml_place(translate(web_post_tr(), wall_locate3(-0.3, 1))), + left_key_place(helpers.translate(web_post(), wall_locate2(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate3(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + default_thumb_ml_place(helpers.translate(web_post_tr(), wall_locate2(-0.3, 1))), + default_thumb_ml_place(helpers.translate(web_post_tr(), wall_locate3(-0.3, 1))), ] )]) - shape = union([shape, - hull_from_shapes( + shape = helpers.union([shape, + helpers.hull_from_shapes( [ - left_key_place(translate(web_post(), wall_locate2(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate3(-1, 0)), cornerrow, -1, low_corner=True, side=side), - default_thumb_ml_place(translate(web_post_tr(), wall_locate2(-0.3, 1))), - default_thumb_ml_place(translate(web_post_tr(), wall_locate3(-0.3, 1))), + left_key_place(helpers.translate(web_post(), wall_locate2(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate3(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + default_thumb_ml_place(helpers.translate(web_post_tr(), wall_locate2(-0.3, 1))), + default_thumb_ml_place(helpers.translate(web_post_tr(), wall_locate3(-0.3, 1))), default_thumb_tl_place(thumb_post_tl()), ] ) ]) # ) - shape = union([shape, hull_from_shapes( + shape = helpers.union([shape, helpers.hull_from_shapes( [ - left_key_place(translate(web_post(), wall_locate1(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate2(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate3(-1, 0)), cornerrow, -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate1(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate2(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate3(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), default_thumb_tl_place(thumb_post_tl()), ] )]) - shape = union([shape, hull_from_shapes( + shape = helpers.union([shape, helpers.hull_from_shapes( [ - left_key_place(web_post(), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate1(-1, 0)), cornerrow, -1, low_corner=True, side=side), - key_place(web_post_bl(), 0, cornerrow), + left_key_place(web_post(), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate1(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + key_place(web_post_bl(), 0, shape_config['cornerrow']), default_thumb_tl_place(thumb_post_tl()), ] )]) - shape = union([shape, hull_from_shapes( + shape = helpers.union([shape, helpers.hull_from_shapes( [ default_thumb_ml_place(web_post_tr()), - default_thumb_ml_place(translate(web_post_tr(), wall_locate1(-0.3, 1))), - default_thumb_ml_place(translate(web_post_tr(), wall_locate2(-0.3, 1))), - default_thumb_ml_place(translate(web_post_tr(), wall_locate3(-0.3, 1))), + default_thumb_ml_place(helpers.translate(web_post_tr(), wall_locate1(-0.3, 1))), + default_thumb_ml_place(helpers.translate(web_post_tr(), wall_locate2(-0.3, 1))), + default_thumb_ml_place(helpers.translate(web_post_tr(), wall_locate3(-0.3, 1))), default_thumb_tl_place(thumb_post_tl()), ] )]) @@ -2725,48 +2726,48 @@ def tbjs_thumb_connection(side='right'): # clunky bit on the top left thumb connection (normal connectors don't work well) hulls = [] hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_bl(), 0, cornerrow), - left_key_place(web_post(), lastrow - 1, -1, side=side, low_corner=True), # left_key_place(translate(web_post(), wall_locate1(-1, 0)), cornerrow, -1, low_corner=True), + key_place(web_post_bl(), 0, shape_config['cornerrow']), + left_key_place(web_post(), shape_config['lastrow'] - 1, -1, side=side, low_corner=True), # left_key_place(helpers.translate(web_post(), wall_locate1(-1, 0)), shape_config['cornerrow'], -1, low_corner=True), tbjs_place(tbjs_post_tl()), ] ) ) hulls.append( - triangle_hulls( + helpers.triangle_hulls( [ - key_place(web_post_bl(), 0, cornerrow), + key_place(web_post_bl(), 0, shape_config['cornerrow']), tbjs_thumb_tl_place(web_post_bl()), - key_place(web_post_br(), 0, cornerrow), + key_place(web_post_br(), 0, shape_config['cornerrow']), tbjs_thumb_tl_place(web_post_tl()), - key_place(web_post_bl(), 1, cornerrow), + key_place(web_post_bl(), 1, shape_config['cornerrow']), tbjs_thumb_tl_place(web_post_tl()), - key_place(web_post_br(), 1, cornerrow), + key_place(web_post_br(), 1, shape_config['cornerrow']), tbjs_thumb_tl_place(web_post_tr()), - key_place(web_post_tl(), 2, lastrow), - key_place(web_post_bl(), 2, lastrow), + key_place(web_post_tl(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 2, shape_config['lastrow']), tbjs_thumb_tl_place(web_post_tr()), - key_place(web_post_bl(), 2, lastrow), + key_place(web_post_bl(), 2, shape_config['lastrow']), tbjs_thumb_mr_place(web_post_tl()), - key_place(web_post_br(), 2, lastrow), - key_place(web_post_bl(), 3, lastrow), + key_place(web_post_br(), 2, shape_config['lastrow']), + key_place(web_post_bl(), 3, shape_config['lastrow']), tbjs_thumb_mr_place(web_post_tr()), tbjs_thumb_mr_place(web_post_tl()), - key_place(web_post_br(), 2, lastrow), - - key_place(web_post_bl(), 3, lastrow), - key_place(web_post_tr(), 2, lastrow), - key_place(web_post_tl(), 3, lastrow), - key_place(web_post_bl(), 3, cornerrow), - key_place(web_post_tr(), 3, lastrow), - key_place(web_post_br(), 3, cornerrow), - key_place(web_post_bl(), 4, cornerrow), + key_place(web_post_br(), 2, shape_config['lastrow']), + + key_place(web_post_bl(), 3, shape_config['lastrow']), + key_place(web_post_tr(), 2, shape_config['lastrow']), + key_place(web_post_tl(), 3, shape_config['lastrow']), + key_place(web_post_bl(), 3, shape_config['cornerrow']), + key_place(web_post_tr(), 3, shape_config['lastrow']), + key_place(web_post_br(), 3, shape_config['cornerrow']), + key_place(web_post_bl(), 4, shape_config['cornerrow']), ] ) ) - shape = union(hulls) + shape = helpers.union(hulls) return shape @@ -2775,38 +2776,38 @@ def tbjs_thumb_walls(): # thumb, walls shape = wall_brace( tbjs_thumb_mr_place, .5, 1, web_post_tr(), - (lambda sh: key_place(sh, 3, lastrow)), 0, -1, web_post_bl(), + (lambda sh: key_place(sh, 3, shape_config['lastrow'])), 0, -1, web_post_bl(), ) - shape = union([shape, wall_brace( + shape = helpers.union([shape, wall_brace( tbjs_thumb_mr_place, .5, 1, web_post_tr(), tbjs_thumb_br_place, 0, -1, web_post_br(), )]) - shape = union([shape, wall_brace( + shape = helpers.union([shape, wall_brace( tbjs_thumb_br_place, 0, -1, web_post_br(), tbjs_thumb_br_place, 0, -1, web_post_bl(), )]) - shape = union([shape, wall_brace( + shape = helpers.union([shape, wall_brace( tbjs_thumb_br_place, 0, -1, web_post_bl(), tbjs_thumb_bl_place, 0, -1, web_post_br(), )]) - shape = union([shape, wall_brace( + shape = helpers.union([shape, wall_brace( tbjs_thumb_bl_place, 0, -1, web_post_br(), tbjs_thumb_bl_place, -1, -1, web_post_bl(), )]) - shape = union([shape, wall_brace( + shape = helpers.union([shape, wall_brace( tbjs_place, -1.5, 0, tbjs_post_tl(), - (lambda sh: left_key_place(sh, lastrow - 1, -1, side=ball_side, low_corner=True)), -1, 0, web_post(), + (lambda sh: left_key_place(sh, shape_config['lastrow'] - 1, -1, side=shape_config['ball_side'], low_corner=True)), -1, 0, web_post(), )]) - shape = union([shape, wall_brace( + shape = helpers.union([shape, wall_brace( tbjs_place, -1.5, 0, tbjs_post_tl(), tbjs_place, -1, 0, tbjs_post_l(), )]) - shape = union([shape, wall_brace( + shape = helpers.union([shape, wall_brace( tbjs_place, -1, 0, tbjs_post_l(), tbjs_thumb_bl_place, -1, 0, web_post_tl(), )]) - shape = union([shape, wall_brace( + shape = helpers.union([shape, wall_brace( tbjs_thumb_bl_place, -1, 0, web_post_tl(), tbjs_thumb_bl_place, -1, -1, web_post_bl(), )]) @@ -2816,51 +2817,51 @@ def tbjs_thumb_walls(): def tbcj_thumb_connection(side='right'): # clunky bit on the top left thumb connection (normal connectors don't work well) - shape = union([bottom_hull( + shape = helpers.union([helpers.bottom_hull( [ - left_key_place(translate(web_post(), wall_locate2(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate3(-1, 0)), cornerrow, -1, low_corner=True, side=side), - default_thumb_ml_place(translate(web_post_tr(), wall_locate2(-0.3, 1))), - default_thumb_ml_place(translate(web_post_tr(), wall_locate3(-0.3, 1))), + left_key_place(helpers.translate(web_post(), wall_locate2(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate3(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + default_thumb_ml_place(helpers.translate(web_post_tr(), wall_locate2(-0.3, 1))), + default_thumb_ml_place(helpers.translate(web_post_tr(), wall_locate3(-0.3, 1))), ] )]) - shape = union([shape, - hull_from_shapes( + shape = helpers.union([shape, + helpers.hull_from_shapes( [ - left_key_place(translate(web_post(), wall_locate2(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate3(-1, 0)), cornerrow, -1, low_corner=True, side=side), - default_thumb_ml_place(translate(web_post_tr(), wall_locate2(-0.3, 1))), - default_thumb_ml_place(translate(web_post_tr(), wall_locate3(-0.3, 1))), + left_key_place(helpers.translate(web_post(), wall_locate2(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate3(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + default_thumb_ml_place(helpers.translate(web_post_tr(), wall_locate2(-0.3, 1))), + default_thumb_ml_place(helpers.translate(web_post_tr(), wall_locate3(-0.3, 1))), default_thumb_tl_place(web_post_tl()), ] ) ]) # ) - shape = union([shape, hull_from_shapes( + shape = helpers.union([shape, helpers.hull_from_shapes( [ - left_key_place(translate(web_post(), wall_locate1(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate2(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate3(-1, 0)), cornerrow, -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate1(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate2(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate3(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), default_thumb_tl_place(web_post_tl()), ] )]) - shape = union([shape, hull_from_shapes( + shape = helpers.union([shape, helpers.hull_from_shapes( [ - left_key_place(web_post(), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate1(-1, 0)), cornerrow, -1, low_corner=True, side=side), - key_place(web_post_bl(), 0, cornerrow), + left_key_place(web_post(), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate1(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + key_place(web_post_bl(), 0, shape_config['cornerrow']), default_thumb_tl_place(web_post_tl()), ] )]) - shape = union([shape, hull_from_shapes( + shape = helpers.union([shape, helpers.hull_from_shapes( [ default_thumb_ml_place(web_post_tr()), - default_thumb_ml_place(translate(web_post_tr(), wall_locate1(-0.3, 1))), - default_thumb_ml_place(translate(web_post_tr(), wall_locate2(-0.3, 1))), - default_thumb_ml_place(translate(web_post_tr(), wall_locate3(-0.3, 1))), + default_thumb_ml_place(helpers.translate(web_post_tr(), wall_locate1(-0.3, 1))), + default_thumb_ml_place(helpers.translate(web_post_tr(), wall_locate2(-0.3, 1))), + default_thumb_ml_place(helpers.translate(web_post_tr(), wall_locate3(-0.3, 1))), default_thumb_tl_place(web_post_tl()), ] )]) @@ -2868,13 +2869,13 @@ def tbcj_thumb_connection(side='right'): return shape def tbcj_thumb_walls(): - shape = union([wall_brace(tbcj_thumb_ml_place, -0.3, 1, web_post_tr(), tbcj_thumb_ml_place, 0, 1, web_post_tl())]) - shape = union([shape, wall_brace(tbcj_thumb_bl_place, 0, 1, web_post_tr(), tbcj_thumb_bl_place, 0, 1, web_post_tl())]) - shape = union([shape, wall_brace(tbcj_thumb_bl_place, -1, 0, web_post_tl(), tbcj_thumb_bl_place, -1, 0, web_post_bl())]) - shape = union([shape, wall_brace(tbcj_thumb_bl_place, -1, 0, web_post_tl(), tbcj_thumb_bl_place, 0, 1, web_post_tl())]) - shape = union([shape, wall_brace(tbcj_thumb_ml_place, 0, 1, web_post_tl(), tbcj_thumb_bl_place, 0, 1, web_post_tr())]) + shape = helpers.union([wall_brace(tbcj_thumb_ml_place, -0.3, 1, web_post_tr(), tbcj_thumb_ml_place, 0, 1, web_post_tl())]) + shape = helpers.union([shape, wall_brace(tbcj_thumb_bl_place, 0, 1, web_post_tr(), tbcj_thumb_bl_place, 0, 1, web_post_tl())]) + shape = helpers.union([shape, wall_brace(tbcj_thumb_bl_place, -1, 0, web_post_tl(), tbcj_thumb_bl_place, -1, 0, web_post_bl())]) + shape = helpers.union([shape, wall_brace(tbcj_thumb_bl_place, -1, 0, web_post_tl(), tbcj_thumb_bl_place, 0, 1, web_post_tl())]) + shape = helpers.union([shape, wall_brace(tbcj_thumb_ml_place, 0, 1, web_post_tl(), tbcj_thumb_bl_place, 0, 1, web_post_tr())]) - corner = box(1,1,tbcj_thickness) + corner = helpers.box(1,1,shape_config['tbcj_thickness']) points = [ (tbcj_thumb_bl_place, -1, 0, web_post_bl()), @@ -2883,85 +2884,85 @@ def tbcj_thumb_walls(): (tbcj_place, 0, -1, tbcj_web_post(2)), (tbcj_place, 1, -1, tbcj_web_post(1)), (tbcj_place, 1, 0, tbcj_web_post(0)), - ((lambda sh: key_place(sh, 3, lastrow)), 0, -1, web_post_bl()), + ((lambda sh: key_place(sh, 3, shape_config['lastrow'])), 0, -1, web_post_bl()), ] for i,_ in enumerate(points[:-1]): (pa, dxa, dya, sa) = points[i] (pb, dxb, dyb, sb) = points[i + 1] - shape = union([shape, wall_brace(pa, dxa, dya, sa, pb, dxb, dyb, sb)]) + shape = helpers.union([shape, wall_brace(pa, dxa, dya, sa, pb, dxb, dyb, sb)]) return shape def mini_thumb_walls(): # thumb, walls - shape = union([wall_brace(mini_thumb_mr_place, 0, -1, web_post_br(), mini_thumb_tr_place, 0, -1, mini_thumb_post_br())]) - shape = union([shape, wall_brace(mini_thumb_mr_place, 0, -1, web_post_br(), mini_thumb_mr_place, 0, -1, web_post_bl())]) - shape = union([shape, wall_brace(mini_thumb_br_place, 0, -1, web_post_br(), mini_thumb_br_place, 0, -1, web_post_bl())]) - shape = union([shape, wall_brace(mini_thumb_bl_place, 0, 1, web_post_tr(), mini_thumb_bl_place, 0, 1, web_post_tl())]) - shape = union([shape, wall_brace(mini_thumb_br_place, -1, 0, web_post_tl(), mini_thumb_br_place, -1, 0, web_post_bl())]) - shape = union([shape, wall_brace(mini_thumb_bl_place, -1, 0, web_post_tl(), mini_thumb_bl_place, -1, 0, web_post_bl())]) + shape = helpers.union([wall_brace(mini_thumb_mr_place, 0, -1, web_post_br(), mini_thumb_tr_place, 0, -1, mini_thumb_post_br())]) + shape = helpers.union([shape, wall_brace(mini_thumb_mr_place, 0, -1, web_post_br(), mini_thumb_mr_place, 0, -1, web_post_bl())]) + shape = helpers.union([shape, wall_brace(mini_thumb_br_place, 0, -1, web_post_br(), mini_thumb_br_place, 0, -1, web_post_bl())]) + shape = helpers.union([shape, wall_brace(mini_thumb_bl_place, 0, 1, web_post_tr(), mini_thumb_bl_place, 0, 1, web_post_tl())]) + shape = helpers.union([shape, wall_brace(mini_thumb_br_place, -1, 0, web_post_tl(), mini_thumb_br_place, -1, 0, web_post_bl())]) + shape = helpers.union([shape, wall_brace(mini_thumb_bl_place, -1, 0, web_post_tl(), mini_thumb_bl_place, -1, 0, web_post_bl())]) # thumb, corners - shape = union([shape, wall_brace(mini_thumb_br_place, -1, 0, web_post_bl(), mini_thumb_br_place, 0, -1, web_post_bl())]) - shape = union([shape, wall_brace(mini_thumb_bl_place, -1, 0, web_post_tl(), mini_thumb_bl_place, 0, 1, web_post_tl())]) + shape = helpers.union([shape, wall_brace(mini_thumb_br_place, -1, 0, web_post_bl(), mini_thumb_br_place, 0, -1, web_post_bl())]) + shape = helpers.union([shape, wall_brace(mini_thumb_bl_place, -1, 0, web_post_tl(), mini_thumb_bl_place, 0, 1, web_post_tl())]) # thumb, tweeners - shape = union([shape, wall_brace(mini_thumb_mr_place, 0, -1, web_post_bl(), mini_thumb_br_place, 0, -1, web_post_br())]) - shape = union([shape, wall_brace(mini_thumb_bl_place, -1, 0, web_post_bl(), mini_thumb_br_place, -1, 0, web_post_tl())]) - shape = union([shape, wall_brace(mini_thumb_tr_place, 0, -1, mini_thumb_post_br(), (lambda sh: key_place(sh, 3, lastrow)), 0, -1, web_post_bl())]) + shape = helpers.union([shape, wall_brace(mini_thumb_mr_place, 0, -1, web_post_bl(), mini_thumb_br_place, 0, -1, web_post_br())]) + shape = helpers.union([shape, wall_brace(mini_thumb_bl_place, -1, 0, web_post_bl(), mini_thumb_br_place, -1, 0, web_post_tl())]) + shape = helpers.union([shape, wall_brace(mini_thumb_tr_place, 0, -1, mini_thumb_post_br(), (lambda sh: key_place(sh, 3, shape_config['lastrow'])), 0, -1, web_post_bl())]) return shape def mini_thumb_connection(side='right'): # clunky bit on the top left thumb connection (normal connectors don't work well) - shape = union([bottom_hull( + shape = helpers.union([helpers.bottom_hull( [ - left_key_place(translate(web_post(), wall_locate2(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate3(-1, 0)), cornerrow, -1, low_corner=True, side=side), - mini_thumb_bl_place(translate(web_post_tr(), wall_locate2(-0.3, 1))), - mini_thumb_bl_place(translate(web_post_tr(), wall_locate3(-0.3, 1))), + left_key_place(helpers.translate(web_post(), wall_locate2(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate3(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + mini_thumb_bl_place(helpers.translate(web_post_tr(), wall_locate2(-0.3, 1))), + mini_thumb_bl_place(helpers.translate(web_post_tr(), wall_locate3(-0.3, 1))), ] )]) - shape = union([shape, - hull_from_shapes( + shape = helpers.union([shape, + helpers.hull_from_shapes( [ - left_key_place(translate(web_post(), wall_locate2(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate3(-1, 0)), cornerrow, -1, low_corner=True, side=side), - mini_thumb_bl_place(translate(web_post_tr(), wall_locate2(-0.3, 1))), - mini_thumb_bl_place(translate(web_post_tr(), wall_locate3(-0.3, 1))), + left_key_place(helpers.translate(web_post(), wall_locate2(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate3(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + mini_thumb_bl_place(helpers.translate(web_post_tr(), wall_locate2(-0.3, 1))), + mini_thumb_bl_place(helpers.translate(web_post_tr(), wall_locate3(-0.3, 1))), mini_thumb_tl_place(web_post_tl()), ] )]) - shape = union([shape, - hull_from_shapes( + shape = helpers.union([shape, + helpers.hull_from_shapes( [ - left_key_place(web_post(), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate1(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate2(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate3(-1, 0)), cornerrow, -1, low_corner=True, side=side), + left_key_place(web_post(), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate1(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate2(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate3(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), mini_thumb_tl_place(web_post_tl()), ] )]) - shape = union([shape, - hull_from_shapes( + shape = helpers.union([shape, + helpers.hull_from_shapes( [ - left_key_place(web_post(), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate1(-1, 0)), cornerrow, -1, low_corner=True, side=side), - key_place(web_post_bl(), 0, cornerrow), + left_key_place(web_post(), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate1(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + key_place(web_post_bl(), 0, shape_config['cornerrow']), mini_thumb_tl_place(web_post_tl()), ] )]) - shape = union([shape, - hull_from_shapes( + shape = helpers.union([shape, + helpers.hull_from_shapes( [ mini_thumb_bl_place(web_post_tr()), - mini_thumb_bl_place(translate(web_post_tr(), wall_locate1(-0.3, 1))), - mini_thumb_bl_place(translate(web_post_tr(), wall_locate2(-0.3, 1))), - mini_thumb_bl_place(translate(web_post_tr(), wall_locate3(-0.3, 1))), + mini_thumb_bl_place(helpers.translate(web_post_tr(), wall_locate1(-0.3, 1))), + mini_thumb_bl_place(helpers.translate(web_post_tr(), wall_locate2(-0.3, 1))), + mini_thumb_bl_place(helpers.translate(web_post_tr(), wall_locate3(-0.3, 1))), mini_thumb_tl_place(web_post_tl()), ] )]) @@ -2971,73 +2972,73 @@ def mini_thumb_connection(side='right'): def minidox_thumb_walls(): # thumb, walls - shape = union([wall_brace(minidox_thumb_tr_place, 0, -1, minidox_thumb_post_br(), minidox_thumb_tr_place, 0, -1, minidox_thumb_post_bl())]) - shape = union([shape, wall_brace(minidox_thumb_tr_place, 0, -1, minidox_thumb_post_bl(), minidox_thumb_tl_place, 0, -1, minidox_thumb_post_br())]) - shape = union([shape, wall_brace(minidox_thumb_tl_place, 0, -1, minidox_thumb_post_br(), minidox_thumb_tl_place, 0, -1, minidox_thumb_post_bl())]) - shape = union([shape, wall_brace(minidox_thumb_tl_place, 0, -1, minidox_thumb_post_bl(), minidox_thumb_ml_place, -1, -1, minidox_thumb_post_br())]) - shape = union([shape, wall_brace(minidox_thumb_ml_place, -1, -1, minidox_thumb_post_br(), minidox_thumb_ml_place, 0, -1, minidox_thumb_post_bl())]) - shape = union([shape, wall_brace(minidox_thumb_ml_place, 0, -1, minidox_thumb_post_bl(), minidox_thumb_ml_place, -1, 0, minidox_thumb_post_bl())]) + shape = helpers.union([wall_brace(minidox_thumb_tr_place, 0, -1, minidox_thumb_post_br(), minidox_thumb_tr_place, 0, -1, minidox_thumb_post_bl())]) + shape = helpers.union([shape, wall_brace(minidox_thumb_tr_place, 0, -1, minidox_thumb_post_bl(), minidox_thumb_tl_place, 0, -1, minidox_thumb_post_br())]) + shape = helpers.union([shape, wall_brace(minidox_thumb_tl_place, 0, -1, minidox_thumb_post_br(), minidox_thumb_tl_place, 0, -1, minidox_thumb_post_bl())]) + shape = helpers.union([shape, wall_brace(minidox_thumb_tl_place, 0, -1, minidox_thumb_post_bl(), minidox_thumb_ml_place, -1, -1, minidox_thumb_post_br())]) + shape = helpers.union([shape, wall_brace(minidox_thumb_ml_place, -1, -1, minidox_thumb_post_br(), minidox_thumb_ml_place, 0, -1, minidox_thumb_post_bl())]) + shape = helpers.union([shape, wall_brace(minidox_thumb_ml_place, 0, -1, minidox_thumb_post_bl(), minidox_thumb_ml_place, -1, 0, minidox_thumb_post_bl())]) # thumb, corners - shape = union([shape, wall_brace(minidox_thumb_ml_place, -1, 0, minidox_thumb_post_bl(), minidox_thumb_ml_place, -1, 0, minidox_thumb_post_tl())]) - shape = union([shape, wall_brace(minidox_thumb_ml_place, -1, 0, minidox_thumb_post_tl(), minidox_thumb_ml_place, 0, 1, minidox_thumb_post_tl())]) + shape = helpers.union([shape, wall_brace(minidox_thumb_ml_place, -1, 0, minidox_thumb_post_bl(), minidox_thumb_ml_place, -1, 0, minidox_thumb_post_tl())]) + shape = helpers.union([shape, wall_brace(minidox_thumb_ml_place, -1, 0, minidox_thumb_post_tl(), minidox_thumb_ml_place, 0, 1, minidox_thumb_post_tl())]) # thumb, tweeners - shape = union([shape, wall_brace(minidox_thumb_ml_place, 0, 1, minidox_thumb_post_tr(), minidox_thumb_ml_place, 0, 1, minidox_thumb_post_tl())]) - shape = union([shape, wall_brace(minidox_thumb_tr_place, 0, -1, minidox_thumb_post_br(), (lambda sh: key_place(sh, 3, lastrow)), 0, -1, web_post_bl())]) + shape = helpers.union([shape, wall_brace(minidox_thumb_ml_place, 0, 1, minidox_thumb_post_tr(), minidox_thumb_ml_place, 0, 1, minidox_thumb_post_tl())]) + shape = helpers.union([shape, wall_brace(minidox_thumb_tr_place, 0, -1, minidox_thumb_post_br(), (lambda sh: key_place(sh, 3, shape_config['lastrow'])), 0, -1, web_post_bl())]) return shape def minidox_thumb_connection(side='right'): # clunky bit on the top left thumb connection (normal connectors don't work well) - shape = union([bottom_hull( + shape = helpers.union([helpers.bottom_hull( [ - left_key_place(translate(web_post(), wall_locate2(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate3(-1, 0)), cornerrow, -1, low_corner=True, side=side), - minidox_thumb_bl_place(translate(minidox_thumb_post_tr(), wall_locate2(-0.3, 1))), - minidox_thumb_bl_place(translate(minidox_thumb_post_tr(), wall_locate3(-0.3, 1))), + left_key_place(helpers.translate(web_post(), wall_locate2(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate3(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + minidox_thumb_bl_place(helpers.translate(minidox_thumb_post_tr(), wall_locate2(-0.3, 1))), + minidox_thumb_bl_place(helpers.translate(minidox_thumb_post_tr(), wall_locate3(-0.3, 1))), ] )]) - shape = union([shape, - hull_from_shapes( + shape = helpers.union([shape, + helpers.hull_from_shapes( [ - left_key_place(translate(web_post(), wall_locate2(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate3(-1, 0)), cornerrow, -1, low_corner=True, side=side), - minidox_thumb_ml_place(translate(minidox_thumb_post_tr(), wall_locate2(-0.3, 1))), - minidox_thumb_ml_place(translate(minidox_thumb_post_tr(), wall_locate3(-0.3, 1))), + left_key_place(helpers.translate(web_post(), wall_locate2(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate3(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + minidox_thumb_ml_place(helpers.translate(minidox_thumb_post_tr(), wall_locate2(-0.3, 1))), + minidox_thumb_ml_place(helpers.translate(minidox_thumb_post_tr(), wall_locate3(-0.3, 1))), minidox_thumb_tl_place(minidox_thumb_post_tl()), ] )]) - shape = union([shape, - hull_from_shapes( + shape = helpers.union([shape, + helpers.hull_from_shapes( [ - left_key_place(web_post(), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate1(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate2(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate3(-1, 0)), cornerrow, -1, low_corner=True, side=side), + left_key_place(web_post(), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate1(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate2(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate3(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), minidox_thumb_tl_place(minidox_thumb_post_tl()), ] )]) - shape = union([shape, - hull_from_shapes( + shape = helpers.union([shape, + helpers.hull_from_shapes( [ - left_key_place(web_post(), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate1(-1, 0)), cornerrow, -1, low_corner=True, side=side), - key_place(web_post_bl(), 0, cornerrow), - # key_place(translate(web_post_bl(), wall_locate1(-1, 0)), cornerrow, -1, low_corner=True), + left_key_place(web_post(), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate1(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + key_place(web_post_bl(), 0, shape_config['cornerrow']), + # key_place(helpers.translate(web_post_bl(), wall_locate1(-1, 0)), shape_config['cornerrow'], -1, low_corner=True), minidox_thumb_tl_place(minidox_thumb_post_tl()), ] )]) - shape = union([shape, - hull_from_shapes( + shape = helpers.union([shape, + helpers.hull_from_shapes( [ minidox_thumb_ml_place(minidox_thumb_post_tr()), - minidox_thumb_ml_place(translate(minidox_thumb_post_tr(), wall_locate1(0, 1))), - minidox_thumb_ml_place(translate(minidox_thumb_post_tr(), wall_locate2(0, 1))), - minidox_thumb_ml_place(translate(minidox_thumb_post_tr(), wall_locate3(0, 1))), + minidox_thumb_ml_place(helpers.translate(minidox_thumb_post_tr(), wall_locate1(0, 1))), + minidox_thumb_ml_place(helpers.translate(minidox_thumb_post_tr(), wall_locate2(0, 1))), + minidox_thumb_ml_place(helpers.translate(minidox_thumb_post_tr(), wall_locate3(0, 1))), minidox_thumb_tl_place(minidox_thumb_post_tl()), ] )]) @@ -3048,71 +3049,71 @@ def minidox_thumb_connection(side='right'): def carbonfet_thumb_walls(): # thumb, walls - shape = union([wall_brace(carbonfet_thumb_mr_place, 0, -1, web_post_br(), carbonfet_thumb_tr_place, 0, -1, web_post_br())]) - shape = union([shape, wall_brace(carbonfet_thumb_mr_place, 0, -1, web_post_br(), carbonfet_thumb_mr_place, 0, -1.15, web_post_bl())]) - shape = union([shape, wall_brace(carbonfet_thumb_br_place, 0, -1, web_post_br(), carbonfet_thumb_br_place, 0, -1, web_post_bl())]) - shape = union([shape, wall_brace(carbonfet_thumb_bl_place, -.3, 1, thumb_post_tr(), carbonfet_thumb_bl_place, 0, 1, thumb_post_tl())]) - shape = union([shape, wall_brace(carbonfet_thumb_br_place, -1, 0, web_post_tl(), carbonfet_thumb_br_place, -1, 0, web_post_bl())]) - shape = union([shape, wall_brace(carbonfet_thumb_bl_place, -1, 0, thumb_post_tl(), carbonfet_thumb_bl_place, -1, 0, web_post_bl())]) + shape = helpers.union([wall_brace(carbonfet_thumb_mr_place, 0, -1, web_post_br(), carbonfet_thumb_tr_place, 0, -1, web_post_br())]) + shape = helpers.union([shape, wall_brace(carbonfet_thumb_mr_place, 0, -1, web_post_br(), carbonfet_thumb_mr_place, 0, -1.15, web_post_bl())]) + shape = helpers.union([shape, wall_brace(carbonfet_thumb_br_place, 0, -1, web_post_br(), carbonfet_thumb_br_place, 0, -1, web_post_bl())]) + shape = helpers.union([shape, wall_brace(carbonfet_thumb_bl_place, -.3, 1, thumb_post_tr(), carbonfet_thumb_bl_place, 0, 1, thumb_post_tl())]) + shape = helpers.union([shape, wall_brace(carbonfet_thumb_br_place, -1, 0, web_post_tl(), carbonfet_thumb_br_place, -1, 0, web_post_bl())]) + shape = helpers.union([shape, wall_brace(carbonfet_thumb_bl_place, -1, 0, thumb_post_tl(), carbonfet_thumb_bl_place, -1, 0, web_post_bl())]) # thumb, corners - shape = union([shape, wall_brace(carbonfet_thumb_br_place, -1, 0, web_post_bl(), carbonfet_thumb_br_place, 0, -1, web_post_bl())]) - shape = union([shape, wall_brace(carbonfet_thumb_bl_place, -1, 0, thumb_post_tl(), carbonfet_thumb_bl_place, 0, 1, thumb_post_tl())]) + shape = helpers.union([shape, wall_brace(carbonfet_thumb_br_place, -1, 0, web_post_bl(), carbonfet_thumb_br_place, 0, -1, web_post_bl())]) + shape = helpers.union([shape, wall_brace(carbonfet_thumb_bl_place, -1, 0, thumb_post_tl(), carbonfet_thumb_bl_place, 0, 1, thumb_post_tl())]) # thumb, tweeners - shape = union([shape, wall_brace(carbonfet_thumb_mr_place, 0, -1.15, web_post_bl(), carbonfet_thumb_br_place, 0, -1, web_post_br())]) - shape = union([shape, wall_brace(carbonfet_thumb_bl_place, -1, 0, web_post_bl(), carbonfet_thumb_br_place, -1, 0, web_post_tl())]) - shape = union([shape, wall_brace(carbonfet_thumb_tr_place, 0, -1, web_post_br(), (lambda sh: key_place(sh, 3, lastrow)), 0, -1, web_post_bl())]) + shape = helpers.union([shape, wall_brace(carbonfet_thumb_mr_place, 0, -1.15, web_post_bl(), carbonfet_thumb_br_place, 0, -1, web_post_br())]) + shape = helpers.union([shape, wall_brace(carbonfet_thumb_bl_place, -1, 0, web_post_bl(), carbonfet_thumb_br_place, -1, 0, web_post_tl())]) + shape = helpers.union([shape, wall_brace(carbonfet_thumb_tr_place, 0, -1, web_post_br(), (lambda sh: key_place(sh, 3, shape_config['lastrow'])), 0, -1, web_post_bl())]) return shape def carbonfet_thumb_connection(side='right'): # clunky bit on the top left thumb connection (normal connectors don't work well) - shape = bottom_hull( + shape = helpers.bottom_hull( [ - left_key_place(translate(web_post(), wall_locate2(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate3(-1, 0)), cornerrow, -1, low_corner=True, side=side), - carbonfet_thumb_bl_place(translate(thumb_post_tr(), wall_locate2(-0.3, 1))), - carbonfet_thumb_bl_place(translate(thumb_post_tr(), wall_locate3(-0.3, 1))), + left_key_place(helpers.translate(web_post(), wall_locate2(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate3(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + carbonfet_thumb_bl_place(helpers.translate(thumb_post_tr(), wall_locate2(-0.3, 1))), + carbonfet_thumb_bl_place(helpers.translate(thumb_post_tr(), wall_locate3(-0.3, 1))), ] ) - shape = union([shape, - hull_from_shapes( + shape = helpers.union([shape, + helpers.hull_from_shapes( [ - left_key_place(translate(web_post(), wall_locate2(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate3(-1, 0)), cornerrow, -1, low_corner=True, side=side), - carbonfet_thumb_bl_place(translate(thumb_post_tr(), wall_locate2(-0.3, 1))), - carbonfet_thumb_bl_place(translate(thumb_post_tr(), wall_locate3(-0.3, 1))), + left_key_place(helpers.translate(web_post(), wall_locate2(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate3(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + carbonfet_thumb_bl_place(helpers.translate(thumb_post_tr(), wall_locate2(-0.3, 1))), + carbonfet_thumb_bl_place(helpers.translate(thumb_post_tr(), wall_locate3(-0.3, 1))), carbonfet_thumb_ml_place(thumb_post_tl()), ] )]) - shape = union([shape, - hull_from_shapes( + shape = helpers.union([shape, + helpers.hull_from_shapes( [ - left_key_place(web_post(), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate1(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate2(-1, 0)), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate3(-1, 0)), cornerrow, -1, low_corner=True, side=side), + left_key_place(web_post(), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate1(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate2(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate3(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), carbonfet_thumb_ml_place(thumb_post_tl()), ] )]) - shape = union([shape, - hull_from_shapes( + shape = helpers.union([shape, + helpers.hull_from_shapes( [ - left_key_place(web_post(), cornerrow, -1, low_corner=True, side=side), - left_key_place(translate(web_post(), wall_locate1(-1, 0)), cornerrow, -1, low_corner=True, side=side), - key_place(web_post_bl(), 0, cornerrow), + left_key_place(web_post(), shape_config['cornerrow'], -1, low_corner=True, side=side), + left_key_place(helpers.translate(web_post(), wall_locate1(-1, 0)), shape_config['cornerrow'], -1, low_corner=True, side=side), + key_place(web_post_bl(), 0, shape_config['cornerrow']), carbonfet_thumb_ml_place(thumb_post_tl()), ] )]) - shape = union([shape, - hull_from_shapes( + shape = helpers.union([shape, + helpers.hull_from_shapes( [ carbonfet_thumb_bl_place(thumb_post_tr()), - carbonfet_thumb_bl_place(translate(thumb_post_tr(), wall_locate1(-0.3, 1))), - carbonfet_thumb_bl_place(translate(thumb_post_tr(), wall_locate2(-0.3, 1))), - carbonfet_thumb_bl_place(translate(thumb_post_tr(), wall_locate3(-0.3, 1))), + carbonfet_thumb_bl_place(helpers.translate(thumb_post_tr(), wall_locate1(-0.3, 1))), + carbonfet_thumb_bl_place(helpers.translate(thumb_post_tr(), wall_locate2(-0.3, 1))), + carbonfet_thumb_bl_place(helpers.translate(thumb_post_tr(), wall_locate3(-0.3, 1))), carbonfet_thumb_ml_place(thumb_post_tl()), ] )]) @@ -3122,7 +3123,7 @@ def carbonfet_thumb_connection(side='right'): def case_walls(side='right'): print('case_walls()') return ( - union([ + helpers.union([ back_wall(), left_wall(side=side), right_wall(), @@ -3135,21 +3136,21 @@ def case_walls(side='right'): def rj9_cube(): debugprint('rj9_cube()') - shape = box(14.78, 13, 22.38) + shape = helpers.box(14.78, 13, 22.38) return shape def rj9_space(): debugprint('rj9_space()') - return translate(rj9_cube(), rj9_position) + return helpers.translate(rj9_cube(), shape_config['rj9_position']) def rj9_holder(): print('rj9_holder()') - shape = union([translate(box(10.78, 9, 18.38), (0, 2, 0)), translate(box(10.78, 13, 5), (0, 0, 5))]) - shape = difference(rj9_cube(), [shape]) - shape = translate(shape, rj9_position) + shape = helpers.union([helpers.translate(box(10.78, 9, 18.38), (0, 2, 0)), helpers.translate(box(10.78, 13, 5), (0, 0, 5))]) + shape = helpers.difference(rj9_cube(), [shape]) + shape = helpers.translate(shape, rj9_position) return shape @@ -3159,16 +3160,16 @@ def rj9_holder(): def usb_holder(): print('usb_holder()') - shape = box( - usb_holder_size[0] + usb_holder_thickness, - usb_holder_size[1], - usb_holder_size[2] + usb_holder_thickness, + shape = helpers.box( + shape_config['usb_holder_size'][0] + shape_config['usb_holder_thickness'], + shape_config['usb_holder_size'][1], + shape_config['usb_holder_size'][2] + shape_config['usb_holder_thickness'], ) - shape = translate(shape, + shape = helpers.translate(shape, ( - usb_holder_position[0], - usb_holder_position[1], - (usb_holder_size[2] + usb_holder_thickness) / 2, + shape_config['usb_holder_position'][0], + shape_config['usb_holder_position'][1], + (shape_config['usb_holder_size'][2] + shape_config['usb_holder_thickness']) / 2, ) ) return shape @@ -3176,12 +3177,12 @@ def usb_holder(): def usb_holder_hole(): debugprint('usb_holder_hole()') - shape = box(*usb_holder_size) - shape = translate(shape, + shape = helpers.box(*shape_config['usb_holder_size']) + shape = helpers.translate(shape, ( - usb_holder_position[0], - usb_holder_position[1], - (usb_holder_size[2] + usb_holder_thickness) / 2, + shape_config['usb_holder_position'][0], + shape_config['usb_holder_position'][1], + (shape_config['usb_holder_size'][2] + shape_config['usb_holder_thickness']) / 2, ) ) return shape @@ -3189,15 +3190,15 @@ def usb_holder_hole(): def external_mount_hole(): print('external_mount_hole()') - shape = box(external_holder_width, 20.0, external_holder_height+.1) - undercut = box(external_holder_width+8, 10.0, external_holder_height+8+.1) - shape = union([shape, translate(undercut,(0, -5, 0))]) + shape = helpers.box(shape_config['external_holder_width'], 20.0, shape_config['external_holder_height']+.1) + undercut = helpers.box(shape_config['external_holder_width']+8, 10.0, shape_config['external_holder_height']+8+.1) + shape = helpers.union([shape, helpers.translate(undercut,(0, -5, 0))]) - shape = translate(shape, + shape = helpers.translate(shape, ( - external_start[0] + external_holder_xoffset, - external_start[1] + external_holder_yoffset, - external_holder_height / 2-.05, + shape_config['external_start'][0] + shape_config['external_holder_xoffset'], + shape_config['external_start'][1] + shape_config['external_holder_yoffset'], + shape_config['external_holder_height'] / 2-.05, ) ) return shape @@ -3205,48 +3206,48 @@ def external_mount_hole(): def generate_trackball(pos, rot): precut = trackball_cutout() - precut = rotate(precut, tb_socket_rotation_offset) - precut = translate(precut, tb_socket_translation_offset) - precut = rotate(precut, rot) - precut = translate(precut, pos) + precut = helpers.rotate(precut, shape_config['tb_socket_rotation_offset']) + precut = helpers.translate(precut, shape_config['tb_socket_translation_offset']) + precut = helpers.rotate(precut, rot) + precut = helpers.translate(precut, pos) shape, cutout, sensor = trackball_socket() - shape = rotate(shape, tb_socket_rotation_offset) - shape = translate(shape, tb_socket_translation_offset) - shape = rotate(shape, rot) - shape = translate(shape, pos) + shape = helpers.rotate(shape, shape_config['tb_socket_rotation_offset']) + shape = helpers.translate(shape, shape_config['tb_socket_translation_offset']) + shape = helpers.rotate(shape, rot) + shape = helpers.translate(shape, pos) - cutout = rotate(cutout, tb_socket_rotation_offset) - cutout = translate(cutout, tb_socket_translation_offset) - # cutout = rotate(cutout, tb_sensor_translation_offset) - # cutout = translate(cutout, tb_sensor_rotation_offset) - cutout = rotate(cutout, rot) - cutout = translate(cutout, pos) + cutout = helpers.rotate(cutout, shape_config['tb_socket_rotation_offset']) + cutout = helpers.translate(cutout, shape_config['tb_socket_translation_offset']) + # cutout = helpers.rotate(cutout, tb_sensor_translation_offset) + # cutout = helpers.translate(cutout, tb_sensor_rotation_offset) + cutout = helpers.rotate(cutout, rot) + cutout = helpers.translate(cutout, pos) # Small adjustment due to line to line surface / minute numerical error issues # Creates small overlap to assist engines in union function later - sensor = rotate(sensor, tb_socket_rotation_offset) - sensor = translate(sensor, tb_socket_translation_offset) - # sensor = rotate(sensor, tb_sensor_translation_offset) - # sensor = translate(sensor, tb_sensor_rotation_offset) - sensor = translate(sensor, (0, 0, .001)) - sensor = rotate(sensor, rot) - sensor = translate(sensor, pos) + sensor = helpers.rotate(sensor, shape_config['tb_socket_rotation_offset']) + sensor = helpers.translate(sensor, shape_config['tb_socket_translation_offset']) + # sensor = helpers.rotate(sensor, tb_sensor_translation_offset) + # sensor = helpers.translate(sensor, tb_sensor_rotation_offset) + sensor = helpers.translate(sensor, (0, 0, .001)) + sensor = helpers.rotate(sensor, rot) + sensor = helpers.translate(sensor, pos) ball = trackball_ball() - ball = rotate(ball, tb_socket_rotation_offset) - ball = translate(ball, tb_socket_translation_offset) - ball = rotate(ball, rot) - ball = translate(ball, pos) + ball = helpers.rotate(ball, shape_config['tb_socket_rotation_offset']) + ball = helpers.translate(ball, shape_config['tb_socket_translation_offset']) + ball = helpers.rotate(ball, rot) + ball = helpers.translate(ball, pos) # return precut, shape, cutout, ball return precut, shape, cutout, sensor, ball def generate_trackball_in_cluster(): - if thumb_style == 'TRACKBALL_ORBYL': + if shape_config['thumb_style'] == 'TRACKBALL_ORBYL': pos, rot = tbjs_thumb_position_rotation() - elif thumb_style == 'TRACKBALL_CJ': + elif shape_config['thumb_style'] == 'TRACKBALL_CJ': pos, rot = tbcj_thumb_position_rotation() return generate_trackball(pos, rot) @@ -3254,31 +3255,31 @@ def generate_trackball_in_cluster(): def tbiw_position_rotation(): base_pt1 = key_position( - list(np.array([-mount_width/2, 0, 0]) + np.array([0, (mount_height / 2), 0])), - 0, cornerrow - tbiw_ball_center_row - 1 + list(np.array([-shape_config['mount_width']/2, 0, 0]) + np.array([0, (shape_config['mount_height'] / 2), 0])), + 0, shape_config['cornerrow'] - shape_config['tbiw_ball_center_row'] - 1 ) base_pt2 = key_position( - list(np.array([-mount_width/2, 0, 0]) + np.array([0, (mount_height / 2), 0])), - 0, cornerrow - tbiw_ball_center_row + 1 + list(np.array([-shape_config['mount_width']/2, 0, 0]) + np.array([0, (shape_config['mount_height'] / 2), 0])), + 0, shape_config['cornerrow'] - shape_config['tbiw_ball_center_row'] + 1 ) base_pt0 = key_position( - list(np.array([-mount_width / 2, 0, 0]) + np.array([0, (mount_height / 2), 0])), - 0, cornerrow - tbiw_ball_center_row + list(np.array([-shape_config['mount_width'] / 2, 0, 0]) + np.array([0, (shape_config['mount_height'] / 2), 0])), + 0, shape_config['cornerrow'] - shape_config['tbiw_ball_center_row'] ) - left_wall_x_offset = tbiw_left_wall_x_offset_override + left_wall_x_offset = shape_config['tbiw_left_wall_x_offset_override'] tbiw_mount_location_xyz = ( (np.array(base_pt1)+np.array(base_pt2))/2. + np.array(((-left_wall_x_offset/2), 0, 0)) - + np.array(tbiw_translational_offset) + + np.array(shape_config['tbiw_translational_offset']) ) # tbiw_mount_location_xyz[2] = (oled_translation_offset[2] + base_pt0[2])/2 angle_x = np.arctan2(base_pt1[2] - base_pt2[2], base_pt1[1] - base_pt2[1]) angle_z = np.arctan2(base_pt1[0] - base_pt2[0], base_pt1[1] - base_pt2[1]) - tbiw_mount_rotation_xyz = (rad2deg(angle_x), 0, rad2deg(angle_z)) + np.array(tbiw_rotation_offset) + tbiw_mount_rotation_xyz = (rad2deg(angle_x), 0, rad2deg(angle_z)) + np.array(shape_config['tbiw_rotation_offset']) return tbiw_mount_location_xyz, tbiw_mount_rotation_xyz @@ -3290,38 +3291,38 @@ def generate_trackball_in_wall(): def oled_position_rotation(side='right'): _oled_center_row = None - if trackball_in_wall and (side == ball_side or ball_side == 'both'): - _oled_center_row = tbiw_oled_center_row - _oled_translation_offset = tbiw_oled_translation_offset - _oled_rotation_offset = tbiw_oled_rotation_offset + if shape_config['trackball_in_wall'] and (side == shape_config['ball_side'] or shape_config['ball_side'] == 'both'): + _oled_center_row = shape_config['tbiw_oled_center_row'] + _oled_translation_offset = shape_config['tbiw_oled_translation_offset'] + _oled_rotation_offset = shape_config['tbiw_oled_rotation_offset'] - elif oled_center_row is not None: - _oled_center_row = oled_center_row - _oled_translation_offset = oled_translation_offset - _oled_rotation_offset = oled_rotation_offset + elif shape_config['oled_center_row'] is not None: + _oled_center_row = shape_config['oled_center_row'] + _oled_translation_offset = shape_config['oled_translation_offset'] + _oled_rotation_offset = shape_config['oled_rotation_offset'] if _oled_center_row is not None: base_pt1 = key_position( - list(np.array([-mount_width/2, 0, 0]) + np.array([0, (mount_height / 2), 0])), 0, _oled_center_row-1 + list(np.array([-shape_config['mount_width']/2, 0, 0]) + np.array([0, (shape_config['mount_height'] / 2), 0])), 0, _oled_center_row-1 ) base_pt2 = key_position( - list(np.array([-mount_width/2, 0, 0]) + np.array([0, (mount_height / 2), 0])), 0, _oled_center_row+1 + list(np.array([-shape_config['mount_width']/2, 0, 0]) + np.array([0, (shape_config['mount_height'] / 2), 0])), 0, _oled_center_row+1 ) base_pt0 = key_position( - list(np.array([-mount_width / 2, 0, 0]) + np.array([0, (mount_height / 2), 0])), 0, _oled_center_row + list(np.array([-shape_config['mount_width'] / 2, 0, 0]) + np.array([0, (shape_config['mount_height'] / 2), 0])), 0, _oled_center_row ) - if trackball_in_wall and (side == ball_side or ball_side == 'both'): - _left_wall_x_offset = tbiw_left_wall_x_offset_override + if shape_config['trackball_in_wall'] and (side == shape_config['ball_side'] or shape_config['ball_side'] == 'both'): + _left_wall_x_offset = shape_config['tbiw_left_wall_x_offset_override'] else: - _left_wall_x_offset = left_wall_x_offset + _left_wall_x_offset = shape_config['left_wall_x_offset'] oled_mount_location_xyz = (np.array(base_pt1)+np.array(base_pt2))/2. + np.array(((-_left_wall_x_offset/2), 0, 0)) + np.array(_oled_translation_offset) oled_mount_location_xyz[2] = (oled_mount_location_xyz[2] + base_pt0[2])/2 angle_x = np.arctan2(base_pt1[2] - base_pt2[2], base_pt1[1] - base_pt2[1]) angle_z = np.arctan2(base_pt1[0] - base_pt2[0], base_pt1[1] - base_pt2[1]) - if trackball_in_wall and (side == ball_side or ball_side == 'both'): + if shape_config['trackball_in_wall'] and (side == shape_config['ball_side'] or shape_config['ball_side'] == 'both'): # oled_mount_rotation_xyz = (0, rad2deg(angle_x), -rad2deg(angle_z)-90) + np.array(oled_rotation_offset) # oled_mount_rotation_xyz = (rad2deg(angle_x)*.707, rad2deg(angle_x)*.707, -45) + np.array(oled_rotation_offset) oled_mount_rotation_xyz = (0, rad2deg(angle_x), -90) + np.array(_oled_rotation_offset) @@ -3331,85 +3332,85 @@ def oled_position_rotation(side='right'): return oled_mount_location_xyz, oled_mount_rotation_xyz def oled_sliding_mount_frame(side='right'): - mount_ext_width = oled_mount_width + 2 * oled_mount_rim + mount_ext_width = shape_config['oled_mount_width'] + 2 * shape_config['oled_mount_rim'] mount_ext_height = ( - oled_mount_height + 2 * oled_edge_overlap_end - + oled_edge_overlap_connector + oled_edge_overlap_clearance - + 2 * oled_mount_rim + shape_config['oled_mount_height'] + 2 * shape_config['oled_edge_overlap_end'] + + shape_config['oled_edge_overlap_connector'] + shape_config['oled_edge_overlap_clearance'] + + 2 * shape_config['oled_mount_rim'] ) - mount_ext_up_height = oled_mount_height + 2 * oled_mount_rim - top_hole_start = -mount_ext_height / 2.0 + oled_mount_rim + oled_edge_overlap_end + oled_edge_overlap_connector - top_hole_length = oled_mount_height + mount_ext_up_height = shape_config['oled_mount_height'] + 2 * shape_config['oled_mount_rim'] + top_hole_start = -mount_ext_height / 2.0 + shape_config['oled_mount_rim'] + shape_config['oled_edge_overlap_end'] + shape_config['oled_edge_overlap_connector'] + top_hole_length = shape_config['oled_mount_height'] - hole = box(mount_ext_width, mount_ext_up_height, oled_mount_cut_depth + .01) - hole = translate(hole, (0., top_hole_start + top_hole_length / 2, 0.)) + hole = helpers.box(mount_ext_width, mount_ext_up_height, shape_config['oled_mount_cut_depth'] + .01) + hole = helpers.translate(hole, (0., top_hole_start + top_hole_length / 2, 0.)) - hole_down = box(mount_ext_width, mount_ext_height, oled_mount_depth + oled_mount_cut_depth / 2) - hole_down = translate(hole_down, (0., 0., -oled_mount_cut_depth / 4)) - hole = union([hole, hole_down]) + hole_down = helpers.box(mount_ext_width, mount_ext_height, shape_config['oled_mount_depth'] + shape_config['oled_mount_cut_depth'] / 2) + hole_down = helpers.translate(hole_down, (0., 0., -shape_config['oled_mount_cut_depth'] / 4)) + hole = helpers.union([hole, hole_down]) - shape = box(mount_ext_width, mount_ext_height, oled_mount_depth) + shape = helpers.box(mount_ext_width, mount_ext_height, shape_config['oled_mount_depth']) - conn_hole_start = -mount_ext_height / 2.0 + oled_mount_rim + conn_hole_start = -mount_ext_height / 2.0 + shape_config['oled_mount_rim'] conn_hole_length = ( - oled_edge_overlap_end + oled_edge_overlap_connector - + oled_edge_overlap_clearance + oled_thickness + shape_config['oled_edge_overlap_end'] + shape_config['oled_edge_overlap_connector'] + + shape_config['oled_edge_overlap_clearance'] + shape_config['oled_thickness'] ) - conn_hole = box(oled_mount_width, conn_hole_length + .01, oled_mount_depth) - conn_hole = translate(conn_hole, ( + conn_hole = helpers.box(shape_config['oled_mount_width'], conn_hole_length + .01, shape_config['oled_mount_depth']) + conn_hole = helpers.translate(conn_hole, ( 0, conn_hole_start + conn_hole_length / 2, - -oled_edge_overlap_thickness + -shape_config['oled_edge_overlap_thickness'] )) end_hole_length = ( - oled_edge_overlap_end + oled_edge_overlap_clearance + shape_config['oled_edge_overlap_end'] + shape_config['oled_edge_overlap_clearance'] ) - end_hole_start = mount_ext_height / 2.0 - oled_mount_rim - end_hole_length - end_hole = box(oled_mount_width, end_hole_length + .01, oled_mount_depth) - end_hole = translate(end_hole, ( + end_hole_start = mount_ext_height / 2.0 - shape_config['oled_mount_rim'] - end_hole_length + end_hole = helpers.box(shape_config['oled_mount_width'], end_hole_length + .01, shape_config['oled_mount_depth']) + end_hole = helpers.translate(end_hole, ( 0, end_hole_start + end_hole_length / 2, - -oled_edge_overlap_thickness + -shape_config['oled_edge_overlap_thickness'] )) - top_hole_start = -mount_ext_height / 2.0 + oled_mount_rim + oled_edge_overlap_end + oled_edge_overlap_connector - top_hole_length = oled_mount_height - top_hole = box(oled_mount_width, top_hole_length, oled_edge_overlap_thickness + oled_thickness - oled_edge_chamfer) - top_hole = translate(top_hole, ( + top_hole_start = -mount_ext_height / 2.0 + shape_config['oled_mount_rim'] + shape_config['oled_edge_overlap_end'] + shape_config['oled_edge_overlap_connector'] + top_hole_length = shape_config['oled_mount_height'] + top_hole = helpers.box(shape_config['oled_mount_width'], top_hole_length, shape_config['oled_edge_overlap_thickness'] + shape_config['oled_thickness'] - shape_config['oled_edge_chamfer']) + top_hole = helpers.translate(top_hole, ( 0, top_hole_start + top_hole_length / 2, - (oled_mount_depth - oled_edge_overlap_thickness - oled_thickness - oled_edge_chamfer) / 2.0 + (shape_config['oled_mount_depth'] - shape_config['oled_edge_overlap_thickness'] - shape_config['oled_thickness'] - shape_config['oled_edge_chamfer']) / 2.0 )) - top_chamfer_1 = box( - oled_mount_width, + top_chamfer_1 = helpers.box( + shape_config['oled_mount_width'] , top_hole_length, 0.01 ) - top_chamfer_2 = box( - oled_mount_width + 2 * oled_edge_chamfer, - top_hole_length + 2 * oled_edge_chamfer, + top_chamfer_2 = helpers.box( + shape_config['oled_mount_width'] + 2 * shape_config['oled_edge_chamfer'], + top_hole_length + 2 * shape_config['oled_edge_chamfer'], 0.01 ) - top_chamfer_1 = translate(top_chamfer_1, (0, 0, -oled_edge_chamfer - .05)) + top_chamfer_1 = helpers.translate(top_chamfer_1, (0, 0, -shape_config['oled_edge_chamfer'] - .05)) - top_chamfer_1 = hull_from_shapes([top_chamfer_1, top_chamfer_2]) + top_chamfer_1 = helpers.hull_from_shapes([top_chamfer_1, top_chamfer_2]) - top_chamfer_1 = translate(top_chamfer_1, ( + top_chamfer_1 = helpers.translate(top_chamfer_1, ( 0, top_hole_start + top_hole_length / 2, - oled_mount_depth / 2.0 + .05 + shape_config['oled_mount_depth'] / 2.0 + .05 )) - top_hole = union([top_hole, top_chamfer_1]) + top_hole = helpers.union([top_hole, top_chamfer_1]) - shape = difference(shape, [conn_hole, top_hole, end_hole]) + shape = helpers.difference(shape, [conn_hole, top_hole, end_hole]) oled_mount_location_xyz, oled_mount_rotation_xyz = oled_position_rotation(side=side) - shape = rotate(shape, oled_mount_rotation_xyz) - shape = translate(shape, + shape = helpers.rotate(shape, oled_mount_rotation_xyz) + shape = helpers.translate(shape, ( oled_mount_location_xyz[0], oled_mount_location_xyz[1], @@ -3417,8 +3418,8 @@ def oled_sliding_mount_frame(side='right'): ) ) - hole = rotate(hole, oled_mount_rotation_xyz) - hole = translate(hole, + hole = helpers.rotate(hole, oled_mount_rotation_xyz) + hole = helpers.translate(hole, ( oled_mount_location_xyz[0], oled_mount_location_xyz[1], @@ -3429,45 +3430,44 @@ def oled_sliding_mount_frame(side='right'): def oled_clip_mount_frame(side='right'): - mount_ext_width = oled_mount_width + 2 * oled_mount_rim + mount_ext_width = shape_config['oled_mount_width'] + 2 * shape_config['oled_mount_rim'] mount_ext_height = ( - oled_mount_height + 2 * oled_clip_thickness - + 2 * oled_clip_undercut + 2 * oled_clip_overhang + 2 * oled_mount_rim + shape_config['oled_mount_height'] + 2 * shape_config['oled_clip_thickness'] + + 2 * shape_config['clip_undercut'] + 2 * shape_config['oled_clip_overhang'] + 2 * shape_config['oled_mount_rim'] ) - hole = box(mount_ext_width, mount_ext_height, oled_mount_cut_depth + .01) + hole = helpers.box(mount_ext_width, mount_ext_height, shape_config['oled_mount_cut_depth'] + .01) - shape = box(mount_ext_width, mount_ext_height, oled_mount_depth) - shape = difference(shape, [box(oled_mount_width, oled_mount_height, oled_mount_depth + .1)]) + shape = helpers.box(mount_ext_width, mount_ext_height, shape_config['oled_mount_depth']) + shape = helpers.difference(shape, [helpers.box(shape_config['oled_mount_width'], shape_config['oled_mount_height'], shape_config['oled_mount_depth'] + .1)]) - clip_slot = box( - oled_clip_width + 2 * oled_clip_width_clearance, - oled_mount_height + 2 * oled_clip_thickness + 2 * oled_clip_overhang, - oled_mount_depth + .1 + clip_slot = helpers.box( + shape_config['oled_clip_width'] + 2 * shape_config['oled_clip_width_clearance'], + shape_config['oled_mount_height'] + 2 * shape_config['oled_clip_thickness'] + 2 * shape_config['oled_clip_overhang'], + shape_config['oled_mount_depth'] + .1 ) - shape = difference(shape, [clip_slot]) - - clip_undercut = box( - oled_clip_width + 2 * oled_clip_width_clearance, - oled_mount_height + 2 * oled_clip_thickness + 2 * oled_clip_overhang + 2 * oled_clip_undercut, - oled_mount_depth + .1 + shape = helpers.difference(shape, [clip_slot]) + clip_undercut = helpers.box( + shape_config['oled_clip_width'] + 2 * shape_config['oled_clip_width_clearance'], + shape_config['oled_mount_height'] + 2 * shape_config['oled_clip_thickness'] + 2 * shape_config['oled_clip_overhang'] + 2 * shape_config['clip_undercut'], + shape_config['oled_mount_depth'] + .1 ) - clip_undercut = translate(clip_undercut, (0., 0., oled_clip_undercut_thickness)) - shape = difference(shape, [clip_undercut]) + clip_undercut = helpers.translate(clip_undercut, (0., 0., shape_config['oled_clip_undercut_thickness'])) + shape = helpers.difference(shape, [clip_undercut]) - plate = box( - oled_mount_width + .1, - oled_mount_height - 2 * oled_mount_connector_hole, - oled_mount_depth - oled_thickness + plate = helpers.box( + shape_config['oled_mount_width'] + .1, + shape_config['oled_mount_height'] - 2 * shape_config['oled_mount_connector_hole'], + shape_config['oled_mount_depth'] - shape_config['oled_thickness'] ) - plate = translate(plate, (0., 0., -oled_thickness / 2.0)) - shape = union([shape, plate]) + plate = helpers.translate(plate, (0., 0., -shape_config['oled_thickness'] / 2.0)) + shape = helpers.union([shape, plate]) oled_mount_location_xyz, oled_mount_rotation_xyz = oled_position_rotation(side=side) - shape = rotate(shape, oled_mount_rotation_xyz) - shape = translate(shape, + shape = helpers.rotate(shape, oled_mount_rotation_xyz) + shape = helpers.translate(shape, ( oled_mount_location_xyz[0], oled_mount_location_xyz[1], @@ -3475,8 +3475,8 @@ def oled_clip_mount_frame(side='right'): ) ) - hole = rotate(hole, oled_mount_rotation_xyz) - hole = translate(hole, + hole = helpers.rotate(hole, oled_mount_rotation_xyz) + hole = helpers.translate(hole, ( oled_mount_location_xyz[0], oled_mount_location_xyz[1], @@ -3488,96 +3488,96 @@ def oled_clip_mount_frame(side='right'): def oled_clip(): - mount_ext_width = oled_mount_width + 2 * oled_mount_rim + mount_ext_width = shape_config['oled_mount_width'] + 2 * shape_config['oled_mount_rim'] mount_ext_height = ( - oled_mount_height + 2 * oled_clip_thickness + 2 * oled_clip_overhang - + 2 * oled_clip_undercut + 2 * oled_mount_rim + shape_config['oled_mount_height'] + 2 * shape_config['oled_clip_thickness'] + 2 * shape_config['oled_clip_overhang'] + + 2 * shape_config['clip_undercut'] + 2 * shape_config['oled_mount_rim'] ) - oled_leg_depth = oled_mount_depth + oled_clip_z_gap + oled_leg_depth = shape_config['oled_mount_depth'] + shape_config['oled_clip_z_gap'] - shape = box(mount_ext_width - .1, mount_ext_height - .1, oled_mount_bezel_thickness) - shape = translate(shape, (0., 0., oled_mount_bezel_thickness / 2.)) + shape = helpers.box(mount_ext_width - .1, mount_ext_height - .1, shape_config['oled_mount_bezel_thickness']) + shape = helpers.translate(shape, (0., 0., shape_config['oled_mount_bezel_thickness'] / 2.)) - hole_1 = box( - oled_screen_width + 2 * oled_mount_bezel_chamfer, - oled_screen_length + 2 * oled_mount_bezel_chamfer, + hole_1 = helpers.box( + shape_config['oled_screen_width'] + 2 * shape_config['oled_mount_bezel_chamfer'], + shape_config['oled_screen_length'] + 2 * shape_config['oled_mount_bezel_chamfer'], .01 ) - hole_2 = box(oled_screen_width, oled_screen_length, 2.05 * oled_mount_bezel_thickness) - hole = hull_from_shapes([hole_1, hole_2]) + hole_2 = helpers.box(shape_config['oled_screen_width'], shape_config['oled_screen_length'], 2.05 * shape_config['oled_mount_bezel_thickness']) + hole = helpers.hull_from_shapes([hole_1, hole_2]) - shape = difference(shape, [translate(hole, (0., 0., oled_mount_bezel_thickness))]) + shape = helpers.difference(shape, [helpers.translate(hole, (0., 0., shape_config['oled_mount_bezel_thickness']))]) - clip_leg = box(oled_clip_width, oled_clip_thickness, oled_leg_depth) - clip_leg = translate(clip_leg, ( + clip_leg = helpers.box(shape_config['oled_clip_width'], shape_config['oled_clip_thickness'], oled_leg_depth) + clip_leg = helpers.translate(clip_leg, ( 0., 0., - # (oled_mount_height+2*oled_clip_overhang+oled_clip_thickness)/2, + # (shape_config['oled_mount_height']+2*shape_config['oled_clip_overhang']+shape_config['oled_clip_thickness'])/2, -oled_leg_depth / 2. )) - latch_1 = box( - oled_clip_width, - oled_clip_overhang + oled_clip_thickness, + latch_1 = helpers.box( + shape_config['oled_clip_width'], + shape_config['oled_clip_overhang'] + shape_config['oled_clip_thickness'], .01 ) - latch_2 = box( - oled_clip_width, - oled_clip_thickness / 2, - oled_clip_extension + latch_2 = helpers.box( + shape_config['oled_clip_width'], + shape_config['oled_clip_thickness'] / 2, + shape_config['oled_clip_extension'] ) - latch_2 = translate(latch_2, ( + latch_2 = helpers.translate(latch_2, ( 0., - -(-oled_clip_thickness / 2 + oled_clip_thickness + oled_clip_overhang) / 2, - -oled_clip_extension / 2 + -(-shape_config['oled_clip_thickness'] / 2 + shape_config['oled_clip_thickness'] + shape_config['oled_clip_overhang']) / 2, + -shape_config['oled_clip_extension'] / 2 )) - latch = hull_from_shapes([latch_1, latch_2]) - latch = translate(latch, ( + latch = helpers.hull_from_shapes([latch_1, latch_2]) + latch = helpers.translate(latch, ( 0., - oled_clip_overhang / 2, + shape_config['oled_clip_overhang'] / 2, -oled_leg_depth )) - clip_leg = union([clip_leg, latch]) + clip_leg = helpers.union([clip_leg, latch]) - clip_leg = translate(clip_leg, ( + clip_leg = helpers.translate(clip_leg, ( 0., - (oled_mount_height + 2 * oled_clip_overhang + oled_clip_thickness) / 2 - oled_clip_y_gap, + (shape_config['oled_mount_height'] + 2 * shape_config['oled_clip_overhang'] + shape_config['oled_clip_thickness']) / 2 - shape_config['oled_clip_y_gap'], 0. )) - shape = union([shape, clip_leg, mirror(clip_leg, 'XZ')]) + shape = helpers.union([shape, clip_leg, helpers.mirror(clip_leg, 'XZ')]) return shape def oled_undercut_mount_frame(side='right'): - mount_ext_width = oled_mount_width + 2 * oled_mount_rim - mount_ext_height = oled_mount_height + 2 * oled_mount_rim - hole = box(mount_ext_width, mount_ext_height, oled_mount_cut_depth + .01) - - shape = box(mount_ext_width, mount_ext_height, oled_mount_depth) - shape = difference(shape, [box(oled_mount_width, oled_mount_height, oled_mount_depth + .1)]) - undercut = box( - oled_mount_width + 2 * oled_mount_undercut, - oled_mount_height + 2 * oled_mount_undercut, - oled_mount_depth) - undercut = translate(undercut, (0., 0., -oled_mount_undercut_thickness)) - shape = difference(shape, [undercut]) + mount_ext_width = shape_config['oled_mount_width'] + 2 * shape_config['oled_mount_rim'] + mount_ext_height = shape_config['oled_mount_height'] + 2 * shape_config['oled_mount_rim'] + hole = helpers.box(mount_ext_width, mount_ext_height, shape_config['oled_mount_cut_depth'] + .01) + + shape = helpers.box(mount_ext_width, mount_ext_height, shape_config['oled_mount_depth']) + shape = helpers.difference(shape, [helpers.box(shape_config['oled_mount_width'], shape_config['oled_mount_height'], shape_config['oled_mount_depth'] + .1)]) + undercut = helpers.box( + shape_config['oled_mount_width'] + 2 * shape_config['oled_mount_undercut'], + shape_config['oled_mount_height'] + 2 * shape_config['oled_mount_undercut'], + shape_config['oled_mount_depth']) + undercut = helpers.translate(undercut, (0., 0., -shape_config['oled_mount_undercut_thickness'])) + shape = helpers.difference(shape, [undercut]) oled_mount_location_xyz, oled_mount_rotation_xyz = oled_position_rotation(side=side) - shape = rotate(shape, oled_mount_rotation_xyz) - shape = translate(shape, ( + shape = helpers.rotate(shape, oled_mount_rotation_xyz) + shape = helpers.translate(shape, ( oled_mount_location_xyz[0], oled_mount_location_xyz[1], oled_mount_location_xyz[2], ) ) - hole = rotate(hole, oled_mount_rotation_xyz) - hole = translate(hole, ( + hole = helpers.rotate(hole, oled_mount_rotation_xyz) + hole = helpers.translate(hole, ( oled_mount_location_xyz[0], oled_mount_location_xyz[1], oled_mount_location_xyz[2], @@ -3594,44 +3594,44 @@ def oled_undercut_mount_frame(side='right'): def teensy_holder(): print('teensy_holder()') - teensy_top_xy = key_position(wall_locate3(-1, 0), 0, centerrow - 1) - teensy_bot_xy = key_position(wall_locate3(-1, 0), 0, centerrow + 1) + teensy_top_xy = key_position(wall_locate3(-1, 0), 0, shape_config['centerrow'] - 1) + teensy_bot_xy = key_position(wall_locate3(-1, 0), 0, shape_config['centerrow'] + 1) teensy_holder_length = teensy_top_xy[1] - teensy_bot_xy[1] teensy_holder_offset = -teensy_holder_length / 2 - teensy_holder_top_offset = (teensy_holder_top_length / 2) - teensy_holder_length + teensy_holder_top_offset = (shape_config['teensy_holder_top_length'] / 2) - teensy_holder_length - s1 = box(3, teensy_holder_length, 6 + teensy_width) - s1 = translate(s1, [1.5, teensy_holder_offset, 0]) + s1 = helpers.box(3, teensy_holder_length, 6 + shape_config['teensy_width']) + s1 = helpers.translate(s1, [1.5, teensy_holder_offset, 0]) - s2 = box(teensy_pcb_thickness, teensy_holder_length, 3) - s2 = translate(s2, + s2 = helpers.box(shape_config['teensy_shape_config']['pcb_thickness'], teensy_holder_length, 3) + s2 = helpers.translate(s2, ( - (teensy_pcb_thickness / 2) + 3, + (shape_config['teensy_shape_config']['pcb_thickness'] / 2) + 3, teensy_holder_offset, - -1.5 - (teensy_width / 2), + -1.5 - (shape_config['teensy_width'] / 2), ) ) - s3 = box(teensy_pcb_thickness, teensy_holder_top_length, 3) - s3 = translate(s3, + s3 = helpers.box(shape_config['teensy_shape_config']['pcb_thickness'], shape_config['teensy_holder_top_length'], 3) + s3 = helpers.translate(s3, [ - (teensy_pcb_thickness / 2) + 3, + (shape_config['teensy_shape_config']['pcb_thickness'] / 2) + 3, teensy_holder_top_offset, - 1.5 + (teensy_width / 2), + 1.5 + (shape_config['teensy_width'] / 2), ] ) - s4 = box(4, teensy_holder_top_length, 4) - s4 = translate(s4, - [teensy_pcb_thickness + 5, teensy_holder_top_offset, 1 + (teensy_width / 2)] + s4 = helpers.box(4, shape_config['teensy_holder_top_length'], 4) + s4 = helpers.translate(s4, + [shape_config['teensy_shape_config']['pcb_thickness'] + 5, teensy_holder_top_offset, 1 + (shape_config['teensy_width'] / 2)] ) - shape = union((s1, s2, s3, s4)) + shape = helpers.union((s1, s2, s3, s4)) - shape = translate(shape, [-teensy_holder_width, 0, 0]) - shape = translate(shape, [-1.4, 0, 0]) - shape = translate(shape, - [teensy_top_xy[0], teensy_top_xy[1] - 1, (6 + teensy_width) / 2] + shape = helpers.translate(shape, [-shape_config['teensy_holder_width'], 0, 0]) + shape = helpers.translate(shape, [-1.4, 0, 0]) + shape = helpers.translate(shape, + [teensy_top_xy[0], teensy_top_xy[1] - 1, (6 + shape_config['teensy_width']) / 2] ) return shape @@ -3640,39 +3640,39 @@ def teensy_holder(): def screw_insert_shape(bottom_radius, top_radius, height): debugprint('screw_insert_shape()') if bottom_radius == top_radius: - base = translate(cylinder(radius=bottom_radius, height=height), + base = helpers.translate(helpers.cylinder(radius=bottom_radius, height=height), (0, 0, -height / 2) ) else: - base = translate(cone(r1=bottom_radius, r2=top_radius, height=height), (0, 0, -height / 2)) + base = helpers.translate(helpers.cone(r1=bottom_radius, r2=top_radius, height=height), (0, 0, -height / 2)) - shape = union(( + shape = helpers.union(( base, - translate(sphere(top_radius), (0, 0, height / 2)), + helpers.translate(helpers.sphere(top_radius), (0, 0, height / 2)), )) return shape def screw_insert(column, row, bottom_radius, top_radius, height, side='right'): debugprint('screw_insert()') - shift_right = column == lastcol + shift_right = column ==shape_config['lastcol'] shift_left = column == 0 shift_up = (not (shift_right or shift_left)) and (row == 0) - shift_down = (not (shift_right or shift_left)) and (row >= lastrow) + shift_down = (not (shift_right or shift_left)) and (row >= shape_config['lastrow']) - if screws_offset == 'INSIDE': + if shape_config['screws_offset'] == 'INSIDE': # debugprint('Shift Inside') - shift_left_adjust = wall_base_x_thickness - shift_right_adjust = -wall_base_x_thickness/2 - shift_down_adjust = -wall_base_y_thickness/2 - shift_up_adjust = -wall_base_y_thickness/3 + shift_left_adjust = shape_config['wall_base_x_thickness'] + shift_right_adjust = -shape_config['wall_base_x_thickness']/2 + shift_down_adjust = -shape_config['wall_base_y_thickness']/2 + shift_up_adjust = -shape_config['wall_base_y_thickness']/3 - elif screws_offset == 'OUTSIDE': + elif shape_config['screws_offset'] == 'OUTSIDE': debugprint('Shift Outside') shift_left_adjust = 0 - shift_right_adjust = wall_base_x_thickness/2 - shift_down_adjust = wall_base_y_thickness*2/3 - shift_up_adjust = wall_base_y_thickness*2/3 + shift_right_adjust = shape_config['wall_base_x_thickness']/2 + shift_down_adjust = shape_config['wall_base_y_thickness']*2/3 + shift_up_adjust = shape_config['wall_base_y_thickness']*2/3 else: # debugprint('Shift Origin') @@ -3683,13 +3683,13 @@ def screw_insert(column, row, bottom_radius, top_radius, height, side='right'): if shift_up: position = key_position( - list(np.array(wall_locate2(0, 1)) + np.array([0, (mount_height / 2) + shift_up_adjust, 0])), + list(np.array(wall_locate2(0, 1)) + np.array([0, (shape_config['mount_height'] / 2) + shift_up_adjust, 0])), column, row, ) elif shift_down: position = key_position( - list(np.array(wall_locate2(0, -1)) - np.array([0, (mount_height / 2) + shift_down_adjust, 0])), + list(np.array(wall_locate2(0, -1)) - np.array([0, (shape_config['mount_height'] / 2) + shift_down_adjust, 0])), column, row, ) @@ -3699,7 +3699,7 @@ def screw_insert(column, row, bottom_radius, top_radius, height, side='right'): ) else: position = key_position( - list(np.array(wall_locate2(1, 0)) + np.array([(mount_height / 2), 0, 0]) + np.array((shift_right_adjust,0,0)) + list(np.array(wall_locate2(1, 0)) + np.array([(shape_config['mount_height'] / 2), 0, 0]) + np.array((shift_right_adjust,0,0)) ), column, row, @@ -3707,27 +3707,27 @@ def screw_insert(column, row, bottom_radius, top_radius, height, side='right'): shape = screw_insert_shape(bottom_radius, top_radius, height) - shape = translate(shape, [position[0], position[1], height / 2]) + shape = helpers.translate(shape, [position[0], position[1], height / 2]) return shape def screw_insert_thumb(bottom_radius, top_radius, height): - if thumb_style == 'MINI': + if shape_config['thumb_style'] == 'MINI': position = thumborigin() position = list(np.array(position) + np.array([-29, -51, -16])) position[2] = 0 - elif thumb_style == 'MINIDOX': + elif shape_config['thumb_style'] == 'MINIDOX': position = thumborigin() position = list(np.array(position) + np.array([-37, -32, -16])) - position[1] = position[1] - .4 * (minidox_Usize - 1) * sa_length + position[1] = position[1] - .4 * (shape_config['minidox_Usize'] - 1) * shape_config['sa_length'] position[2] = 0 - elif thumb_style == 'CARBONFET': + elif shape_config['thumb_style'] == 'CARBONFET': position = thumborigin() position = list(np.array(position) + np.array([-48, -37, 0])) position[2] = 0 - elif thumb_style == 'TRACKBALL': + elif shape_config['thumb_style'] == 'TRACKBALL': position = thumborigin() position = list(np.array(position) + np.array([-72, -40, -16])) position[2] = 0 @@ -3738,19 +3738,19 @@ def screw_insert_thumb(bottom_radius, top_radius, height): position[2] = 0 shape = screw_insert_shape(bottom_radius, top_radius, height) - shape = translate(shape, [position[0], position[1], height / 2]) + shape = helpers.translate(shape, [position[0], position[1], height / 2]) return shape def screw_insert_all_shapes(bottom_radius, top_radius, height, offset=0, side='right'): print('screw_insert_all_shapes()') shape = ( - translate(screw_insert(0, 0, bottom_radius, top_radius, height, side=side), (0, 0, offset)), - translate(screw_insert(0, lastrow-1, bottom_radius, top_radius, height, side=side), (0, left_wall_lower_y_offset, offset)), - translate(screw_insert(3, lastrow, bottom_radius, top_radius, height, side=side), (0, 0, offset)), - translate(screw_insert(3, 0, bottom_radius, top_radius, height, side=side), (0,0, offset)), - translate(screw_insert(lastcol, 0, bottom_radius, top_radius, height, side=side), (0, 0, offset)), - translate(screw_insert(lastcol, lastrow-1, bottom_radius, top_radius, height, side=side), (0, 0, offset)), - translate(screw_insert_thumb(bottom_radius, top_radius, height), (0, 0, offset)), + helpers.translate(screw_insert(0, 0, bottom_radius, top_radius, height, side=side), (0, 0, offset)), + helpers.translate(screw_insert(0, shape_config['lastrow']-1, bottom_radius, top_radius, height, side=side), (0, shape_config['left_wall_lower_y_offset'], offset)), + helpers.translate(screw_insert(3, shape_config['lastrow'], bottom_radius, top_radius, height, side=side), (0, 0, offset)), + helpers.translate(screw_insert(3, 0, bottom_radius, top_radius, height, side=side), (0,0, offset)), + helpers.translate(screw_insert(shape_config['lastcol'], 0, bottom_radius, top_radius, height, side=side), (0, 0, offset)), + helpers.translate(screw_insert(shape_config['lastcol'], shape_config['lastrow']-1, bottom_radius, top_radius, height, side=side), (0, 0, offset)), + helpers.translate(screw_insert_thumb(bottom_radius, top_radius, height), (0, 0, offset)), ) return shape @@ -3760,14 +3760,14 @@ def screw_insert_all_shapes(bottom_radius, top_radius, height, offset=0, side='r def screw_insert_holes(side='right'): return screw_insert_all_shapes( - screw_insert_bottom_radius, screw_insert_top_radius, screw_insert_height+.02, offset=-.01, side=side + shape_config['screw_insert_bottom_radius'], shape_config['screw_insert_top_radius'], shape_config['screw_insert_height']+.02, offset=-.01, side=side ) def screw_insert_outers(side='right'): return screw_insert_all_shapes( - screw_insert_bottom_radius + 1.6, - screw_insert_top_radius + 1.6, - screw_insert_height + 1.5, + shape_config['screw_insert_bottom_radius'] + 1.6, + shape_config['screw_insert_top_radius'] + 1.6, + shape_config['screw_insert_height'] + 1.5, side=side ) @@ -3779,164 +3779,164 @@ def screw_insert_screw_holes(side='right'): def wire_post(direction, offset): debugprint('wire_post()') - s1 = box( - wire_post_diameter, wire_post_diameter, wire_post_height + s1 = helpers.box( + shape_config['wire_post_diameter'], shape_config['wire_post_diameter'], shape_config['wire_post_height'] ) - s1 = translate(s1, [0, -wire_post_diameter * 0.5 * direction, 0]) + s1 = helpers.translate(s1, [0, -shape_config['wire_post_diameter'] * 0.5 * direction, 0]) - s2 = box( - wire_post_diameter, wire_post_overhang, wire_post_diameter + s2 = helpers.box( + shape_config['wire_post_diameter'], shape_config['wire_post_overhang'], shape_config['wire_post_diameter'] ) - s2 = translate(s2, - [0, -wire_post_overhang * 0.5 * direction, -wire_post_height / 2] + s2 = helpers.translate(s2, + [0, -shape_config['wire_post_overhang'] * 0.5 * direction, -shape_config['wire_post_height'] / 2] ) - shape = union((s1, s2)) - shape = translate(shape, [0, -offset, (-wire_post_height / 2) + 3]) - shape = rotate(shape, [-alpha / 2, 0, 0]) - shape = translate(shape, (3, -mount_height / 2, 0)) + shape = helpers.union((s1, s2)) + shape = helpers.translate(shape, [0, -offset, (-shape_config['wire_post_height'] / 2) + 3]) + shape = helpers.rotate(shape, [-shape_config['alpha'] / 2, 0, 0]) + shape = helpers.translate(shape, (3, -shape_config['mount_height'] / 2, 0)) return shape def wire_posts(): debugprint('wire_posts()') - shape = default_thumb_ml_place(wire_post(1, 0).translate([-5, 0, -2])) - shape = union([shape, default_thumb_ml_place(wire_post(-1, 6).translate([0, 0, -2.5]))]) - shape = union([shape, default_thumb_ml_place(wire_post(1, 0).translate([5, 0, -2]))]) + shape = default_thumb_ml_place(wire_post(1, 0).helpers.translate([-5, 0, -2])) + shape = helpers.union([shape, default_thumb_ml_place(wire_post(-1, 6).helpers.translate([0, 0, -2.5]))]) + shape = helpers.union([shape, default_thumb_ml_place(wire_post(1, 0).helpers.translate([5, 0, -2]))]) - for column in range(lastcol): - for row in range(lastrow - 1): - shape = union([ + for column in range(shape_config['lastcol']): + for row in range(shape_config['lastrow'] - 1): + shape = helpers.union([ shape, - key_place(wire_post(1, 0).translate([-5, 0, 0]), column, row), - key_place(wire_post(-1, 6).translate([0, 0, 0]), column, row), - key_place(wire_post(1, 0).translate([5, 0, 0]), column, row), + key_place(wire_post(1, 0).helpers.translate([-5, 0, 0]), column, row), + key_place(wire_post(-1, 6).helpers.translate([0, 0, 0]), column, row), + key_place(wire_post(1, 0).helpers.translate([5, 0, 0]), column, row), ]) return shape def model_side(side="right"): print('model_right()') - shape = union([key_holes(side=side)]) + shape = helpers.union([key_holes(side=side)]) if debug_exports: - export_file(shape=shape, fname=path.join(r"..", "things", r"debug_key_plates")) + helpers.export_file(shape=shape, fname=path.join(r"..", "things", r"debug_key_plates")) connector_shape = connectors() - shape = union([shape, connector_shape]) + shape = helpers.union([shape, connector_shape]) if debug_exports: - export_file(shape=shape, fname=path.join(r"..", "things", r"debug_connector_shape")) + helpers.export_file(shape=shape, fname=path.join(r"..", "things", r"debug_connector_shape")) thumb_shape = thumb(side=side) if debug_exports: - export_file(shape=thumb_shape, fname=path.join(r"..", "things", r"debug_thumb_shape")) - shape = union([shape, thumb_shape]) + helpers.export_file(shape=thumb_shape, fname=path.join(r"..", "things", r"debug_thumb_shape")) + shape = helpers.union([shape, thumb_shape]) thumb_connector_shape = thumb_connectors(side=side) - shape = union([shape, thumb_connector_shape]) + shape = helpers.union([shape, thumb_connector_shape]) if debug_exports: - export_file(shape=shape, fname=path.join(r"..", "things", r"debug_thumb_connector_shape")) + helpers.export_file(shape=shape, fname=path.join(r"..", "things", r"debug_thumb_connector_shape")) walls_shape = case_walls(side=side) if debug_exports: - export_file(shape=walls_shape, fname=path.join(r"..", "things", r"debug_walls_shape")) - s2 = union([walls_shape]) - s2 = union([s2, *screw_insert_outers(side=side)]) + helpers.export_file(shape=walls_shape, fname=path.join(r"..", "things", r"debug_walls_shape")) + s2 = helpers.union([walls_shape]) + s2 = helpers.union([s2, *screw_insert_outers(side=side)]) - if controller_mount_type in ['RJ9_USB_TEENSY', 'USB_TEENSY']: - s2 = union([s2, teensy_holder()]) + if shape_config['controller_mount_type'] in ['RJ9_USB_TEENSY', 'USB_TEENSY']: + s2 = helpers.union([s2, teensy_holder()]) - if controller_mount_type in ['RJ9_USB_TEENSY', 'RJ9_USB_WALL', 'USB_WALL', 'USB_TEENSY']: - s2 = union([s2, usb_holder()]) - s2 = difference(s2, [usb_holder_hole()]) + if shape_config['controller_mount_type'] in ['RJ9_USB_TEENSY', 'RJ9_USB_WALL', 'USB_WALL', 'USB_TEENSY']: + s2 = helpers.union([s2, usb_holder()]) + s2 = helpers.difference(s2, [usb_holder_hole()]) - if controller_mount_type in ['RJ9_USB_TEENSY', 'RJ9_USB_WALL']: - s2 = difference(s2, [rj9_space()]) + if shape_config['controller_mount_type'] in ['RJ9_USB_TEENSY', 'RJ9_USB_WALL']: + s2 = helpers.difference(s2, [rj9_space()]) - if controller_mount_type in ['EXTERNAL']: - s2 = difference(s2, [external_mount_hole()]) + if shape_config['controller_mount_type'] in ['EXTERNAL']: + s2 = helpers.difference(s2, [external_mount_hole()]) - if controller_mount_type in ['None']: + if shape_config['controller_mount_type'] in ['None']: 0 # do nothing, only here to expressly state inaction. - s2 = difference(s2, [union(screw_insert_holes(side=side))]) - shape = union([shape, s2]) + s2 = helpers.difference(s2, [helpers.union(screw_insert_holes(side=side))]) + shape = helpers.union([shape, s2]) - if controller_mount_type in ['RJ9_USB_TEENSY', 'RJ9_USB_WALL']: - shape = union([shape, rj9_holder()]) + if shape_config['controller_mount_type'] in ['RJ9_USB_TEENSY', 'RJ9_USB_WALL']: + shape = helpers.union([shape, rj9_holder()]) - if oled_mount_type == "UNDERCUT": + if shape_config['oled_mount_type'] == "UNDERCUT": hole, frame = oled_undercut_mount_frame(side=side) - shape = difference(shape, [hole]) - shape = union([shape, frame]) + shape = helpers.difference(shape, [hole]) + shape = helpers.union([shape, frame]) - elif oled_mount_type == "SLIDING": + elif shape_config['oled_mount_type'] == "SLIDING": hole, frame = oled_sliding_mount_frame(side=side) - shape = difference(shape, [hole]) - shape = union([shape, frame]) + shape = helpers.difference(shape, [hole]) + shape = helpers.union([shape, frame]) - elif oled_mount_type == "CLIP": + elif shape_config['oled_mount_type'] == "CLIP": hole, frame = oled_clip_mount_frame(side=side) - shape = difference(shape, [hole]) - shape = union([shape, frame]) + shape = helpers.difference(shape, [hole]) + shape = helpers.union([shape, frame]) - if trackball_in_wall and (side == ball_side or ball_side == 'both'): + if shape_config['trackball_in_wall'] and (side == shape_config['ball_side'] or shape_config['ball_side'] == 'both'): tbprecut, tb, tbcutout, sensor, ball = generate_trackball_in_wall() - shape = difference(shape, [tbprecut]) - # export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_1")) - shape = union([shape, tb]) - # export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_2")) - shape = difference(shape, [tbcutout]) - # export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_3a")) - # export_file(shape=add([shape, sensor]), fname=path.join(save_path, config_name + r"_test_3b")) - shape = union([shape, sensor]) + shape = helpers.difference(shape, [tbprecut]) + # helpers.export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_1")) + shape = helpers.union([shape, tb]) + # helpers.export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_2")) + shape = helpers.difference(shape, [tbcutout]) + # helpers.export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_3a")) + # helpers.export_file(shape=helpers.add([shape, sensor]), fname=path.join(save_path, config_name + r"_test_3b")) + shape = helpers.union([shape, sensor]) - if show_caps: - shape = add([shape, ball]) + if shape_config['show_caps']: + shape = helpers.add([shape, ball]) - if (trackball_in_wall or ('TRACKBALL' in thumb_style)) and (side == ball_side or ball_side == 'both'): + if (shape_config['trackball_in_wall'] or ('TRACKBALL' in shape_config['thumb_style'])) and (side == shape_config['ball_side'] or shape_config['ball_side'] == 'both'): tbprecut, tb, tbcutout, sensor, ball = generate_trackball_in_cluster() - shape = difference(shape, [tbprecut]) - # export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_1")) - shape = union([shape, tb]) - # export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_2")) - shape = difference(shape, [tbcutout]) - # export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_3a")) - # export_file(shape=add([shape, sensor]), fname=path.join(save_path, config_name + r"_test_3b")) - shape = union([shape, sensor]) + shape = helpers.difference(shape, [tbprecut]) + # helpers.export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_1")) + shape = helpers.union([shape, tb]) + # helpers.export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_2")) + shape = helpers.difference(shape, [tbcutout]) + # helpers.export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_3a")) + # helpers.export_file(shape=helpers.add([shape, sensor]), fname=path.join(save_path, config_name + r"_test_3b")) + shape = helpers.union([shape, sensor]) - if show_caps: - shape = add([shape, ball]) + if shape_config['show_caps']: + shape = helpers.add([shape, ball]) - block = box(350, 350, 40) - block = translate(block, (0, 0, -20)) - shape = difference(shape, [block]) + block = helpers.box(350, 350, 40) + block = helpers.translate(block, (0, 0, -20)) + shape = helpers.difference(shape, [block]) - if show_caps: - shape = add([shape, thumbcaps(side=side)]) - shape = add([shape, caps()]) + if shape_config['show_caps']: + shape = helpers.add([shape, thumbcaps(side=side)]) + shape = helpers.add([shape, caps()]) if side == "left": - shape = mirror(shape, 'YZ') + shape = helpers.mirror(shape, 'YZ') return shape # NEEDS TO BE SPECIAL FOR CADQUERY def baseplate(wedge_angle=None, side='right'): - if ENGINE == 'cadquery': + if shape_config['ENGINE'] == 'cadquery': # shape = mod_r - shape = union([case_walls(side=side), *screw_insert_outers(side=side)]) - # tool = translate(screw_insert_screw_holes(side=side), [0, 0, -10]) - tool = screw_insert_all_shapes(screw_hole_diameter/2., screw_hole_diameter/2., 350, side=side) + shape = helpers.union([case_walls(side=side), *screw_insert_outers(side=side)]) + # tool = helpers.translate(screw_insert_screw_holes(side=side), [0, 0, -10]) + tool = screw_insert_all_shapes(shape_config['screw_hole_diameter']/2., shape_config['screw_hole_diameter']/2., 350, side=side) for item in tool: - item = translate(item, [0, 0, -10]) - shape = difference(shape, [item]) + item = helpers.translate(item, [0, 0, -10]) + shape = helpers.difference(shape, [item]) - shape = translate(shape, (0, 0, -0.0001)) + shape = helpers.translate(shape, (0, 0, -0.0001)) square = cq.Workplane('XY').rect(1000, 1000) for wire in square.wires().objects: - plane = cq.Workplane('XY').add(cq.Face.makeFromWires(wire)) - shape = intersect(shape, plane) + plane = cq.Workplane('XY').helpers.add(cq.Face.makeFromWires(wire)) + shape = helpers.intersect(shape, plane) outside = shape.vertices(cq.DirectionMinMaxSelector(cq.Vector(1, 0, 0), True)).objects[0] sizes = [] @@ -3959,12 +3959,12 @@ def baseplate(wedge_angle=None, side='right'): debugprint(sizes) inner_wire = base_wires[inner_index] - # inner_plate = cq.Workplane('XY').add(cq.Face.makeFromWires(inner_wire)) + # inner_plate = cq.Workplane('XY').helpers.add(cq.Face.makeFromWires(inner_wire)) if wedge_angle is not None: - cq.Workplane('XY').add(cq.Solid.revolve(outerWire, innerWires, angleDegrees, axisStart, axisEnd)) + cq.Workplane('XY').helpers.add(cq.Solid.revolve(outerWire, innerWires, angleDegrees, axisStart, axisEnd)) else: - inner_shape = cq.Workplane('XY').add(cq.Solid.extrudeLinear(outerWire=inner_wire, innerWires=[], vecNormal=cq.Vector(0, 0, base_thickness))) - inner_shape = translate(inner_shape, (0, 0, -base_rim_thickness)) + inner_shape = cq.Workplane('XY').helpers.add(cq.Solid.extrudeLinear(outerWire=inner_wire, innerWires=[], vecNormal=cq.Vector(0, 0, shape_config['base_thickness']))) + inner_shape = helpers.translate(inner_shape, (0, 0, -shape_config['base_rim_thickness'])) holes = [] for i in range(len(base_wires)): @@ -3972,84 +3972,81 @@ def baseplate(wedge_angle=None, side='right'): holes.append(base_wires[i]) cutout = [*holes, inner_wire] - shape = cq.Workplane('XY').add(cq.Solid.extrudeLinear(outer_wire, cutout, cq.Vector(0, 0, base_rim_thickness))) + shape = cq.Workplane('XY').helpers.add(cq.Solid.extrudeLinear(outer_wire, cutout, cq.Vector(0, 0, shape_config['base_rim_thickness']))) hole_shapes=[] for hole in holes: loc = hole.Center() hole_shapes.append( - translate( - cylinder(screw_cbore_diameter/2.0, screw_cbore_depth), + helpers.translate( + helpers.cylinder(shape_config['screw_cbore_diameter']/2.0, shape_config['screw_cbore_depth']), (loc.x, loc.y, 0) - # (loc.x, loc.y, screw_cbore_depth/2) + # (loc.x, loc.y, shape_config['screw_cbore_depth']/2) ) ) - shape = difference(shape, hole_shapes) - shape = translate(shape, (0, 0, -base_rim_thickness)) - shape = union([shape, inner_shape]) + shape = helpers.difference(shape, hole_shapes) + shape = helpers.translate(shape, (0, 0, -shape_config['base_rim_thickness'])) + shape = helpers.union([shape, inner_shape]) return shape else: - shape = union([ + shape = helpers.union([ case_walls(side=side), *screw_insert_outers(side=side) ]) - tool = translate(union(screw_insert_screw_holes(side=side)), [0, 0, -10]) - base = box(1000, 1000, .01) + tool = helpers.translate(helpers.union(screw_insert_screw_holes(side=side)), [0, 0, -10]) + base = helpers.box(1000, 1000, .01) shape = shape - tool - shape = intersect(shape, base) + shape = helpers.intersect(shape, base) - shape = translate(shape, [0, 0, -0.001]) + shape = helpers.translate(shape, [0, 0, -0.001]) return sl.projection(cut=True)(shape) def run(opts): setup(opts) - print(save_path) - print(parts_path) - exit(0) mod_r = model_side(side="right") - export_file(shape=mod_r, fname=path.join(save_path, config_name + r"_right")) + helpers.export_file(shape=mod_r, fname=path.join(save_path, opts['config']['name'] + r"_right")) base = baseplate(side='right') - 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")) + helpers.export_file(shape=base, fname=path.join(save_path, opts['config']['name'] + r"_right_plate")) + helpers.export_dxf(shape=base, fname=path.join(save_path, opts['config']['name'] + r"_right_plate")) - if symmetry == "asymmetric": + if shape_config['symmetry'] == "asymmetric": mod_l = model_side(side="left") - export_file(shape=mod_l, fname=path.join(save_path, config_name + r"_left")) + helpers.export_file(shape=mod_l, fname=path.join(save_path, opts['config']['name'] + r"_left")) - base_l = mirror(baseplate(side='left'), 'YZ') - export_file(shape=base_l, fname=path.join(save_path, config_name + r"_left_plate")) - export_dxf(shape=base_l, fname=path.join(save_path, config_name + r"_left_plate")) + base_l = helpers.mirror(baseplate(side='left'), 'YZ') + helpers.export_file(shape=base_l, fname=path.join(save_path, opts['config']['name'] + r"_left_plate")) + helpers.export_dxf(shape=base_l, fname=path.join(save_path, opts['config']['name'] + r"_left_plate")) else: - export_file(shape=mirror(mod_r, 'YZ'), fname=path.join(save_path, config_name + r"_left")) + helpers.export_file(shape=helpers.mirror(mod_r, 'YZ'), fname=path.join(save_path, opts['config']['name'] + r"_left")) - lbase = mirror(base, 'YZ') - 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")) + lbase = helpers.mirror(base, 'YZ') + helpers.export_file(shape=lbase, fname=path.join(save_path, opts['config']['name'] + r"_left_plate")) + helpers.export_dxf(shape=lbase, fname=path.join(save_path, opts['config']['name'] + r"_left_plate")) - if oled_mount_type == 'UNDERCUT': - export_file(shape=oled_undercut_mount_frame()[1], fname=path.join(save_path, config_name + r"_oled_undercut_test")) + if shape_config['oled_mount_type'] == 'UNDERCUT': + helpers.export_file(shape=oled_undercut_mount_frame()[1], fname=path.join(save_path, opts['config']['name'] + r"_oled_undercut_test")) - if oled_mount_type == 'SLIDING': - export_file(shape=oled_sliding_mount_frame()[1], fname=path.join(save_path, config_name + r"_oled_sliding_test")) + if shape_config['oled_mount_type'] == 'SLIDING': + helpers.export_file(shape=oled_sliding_mount_frame()[1], fname=path.join(save_path, opts['config']['name'] + r"_oled_sliding_test")) - if oled_mount_type == 'CLIP': - oled_mount_location_xyz = (0.0, 0.0, -oled_mount_depth / 2) + if shape_config['oled_mount_type'] == 'CLIP': + oled_mount_location_xyz = (0.0, 0.0, -shape_config['oled_mount_depth'] / 2) oled_mount_rotation_xyz = (0.0, 0.0, 0.0) - 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(save_path, config_name + r"_oled_clip_test")) - export_file(shape=union((oled_clip_mount_frame()[1], oled_clip())), - fname=path.join(save_path, config_name + r"_oled_clip_assy_test")) + helpers.export_file(shape=oled_clip(), fname=path.join(save_path, opts['config']['name'] + r"_oled_clip")) + helpers.export_file(shape=oled_clip_mount_frame()[1], + fname=path.join(save_path, opts['config']['name'] + r"_oled_clip_test")) + helpers.export_file(shape=helpers.union((oled_clip_mount_frame()[1], oled_clip())), + fname=path.join(save_path, opts['config']['name'] + r"_oled_clip_assy_test")) # base = baseplate() -# export_file(shape=base, fname=path.join(save_path, config_name + r"_plate")) +# helpers.export_file(shape=base, fname=path.join(save_path, opts['config']['name'] + r"_plate")) From 7b2f7d3cfacd26e1c454e44366bb9118df7a5266 Mon Sep 17 00:00:00 2001 From: Edward Date: Tue, 24 Aug 2021 07:57:11 -0400 Subject: [PATCH 06/10] fixed global references --- src/dactyl_manuform.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dactyl_manuform.py b/src/dactyl_manuform.py index a4de8b857..62c941e46 100644 --- a/src/dactyl_manuform.py +++ b/src/dactyl_manuform.py @@ -3148,9 +3148,9 @@ def rj9_space(): def rj9_holder(): print('rj9_holder()') - shape = helpers.union([helpers.translate(box(10.78, 9, 18.38), (0, 2, 0)), helpers.translate(box(10.78, 13, 5), (0, 0, 5))]) + shape = helpers.union([helpers.translate(helpers.box(10.78, 9, 18.38), (0, 2, 0)), helpers.translate(helpers.box(10.78, 13, 5), (0, 0, 5))]) shape = helpers.difference(rj9_cube(), [shape]) - shape = helpers.translate(shape, rj9_position) + shape = helpers.translate(shape, shape_config['rj9_position']) return shape From bd6955140e44768472e0eb8ce0d9c5ed0c0a797a Mon Sep 17 00:00:00 2001 From: Edward Date: Tue, 24 Aug 2021 07:57:43 -0400 Subject: [PATCH 07/10] import cadquery/solid for use in baseplate function --- src/dactyl_manuform.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dactyl_manuform.py b/src/dactyl_manuform.py index 62c941e46..201a00375 100644 --- a/src/dactyl_manuform.py +++ b/src/dactyl_manuform.py @@ -1,3 +1,4 @@ +from helpers_cadquery import export_file import numpy as np from numpy import pi import math @@ -8,7 +9,7 @@ from . import default_configuration from scipy.spatial import ConvexHull as sphull import solid as sl - +import cadquery as cq debug_exports = False debug_trace = False @@ -3921,6 +3922,7 @@ def model_side(side="right"): # NEEDS TO BE SPECIAL FOR CADQUERY +# todo: refactor so this file doesn't need to import solid/cadquery def baseplate(wedge_angle=None, side='right'): if shape_config['ENGINE'] == 'cadquery': # shape = mod_r From e872d8bdc5a873b51c9f66c64b969934f57ca44f Mon Sep 17 00:00:00 2001 From: Edward Date: Tue, 24 Aug 2021 07:58:39 -0400 Subject: [PATCH 08/10] added export_file function --- src/dactyl_manuform.py | 63 ++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/src/dactyl_manuform.py b/src/dactyl_manuform.py index 201a00375..d00b8b778 100644 --- a/src/dactyl_manuform.py +++ b/src/dactyl_manuform.py @@ -3821,22 +3821,22 @@ def model_side(side="right"): print('model_right()') shape = helpers.union([key_holes(side=side)]) if debug_exports: - helpers.export_file(shape=shape, fname=path.join(r"..", "things", r"debug_key_plates")) + export_file(shape=shape, part_name=r"debug_key_plates") connector_shape = connectors() shape = helpers.union([shape, connector_shape]) if debug_exports: - helpers.export_file(shape=shape, fname=path.join(r"..", "things", r"debug_connector_shape")) + export_file(shape=shape, part_name=r"debug_connector_shape") thumb_shape = thumb(side=side) if debug_exports: - helpers.export_file(shape=thumb_shape, fname=path.join(r"..", "things", r"debug_thumb_shape")) + export_file(shape=thumb_shape, part_name=r"debug_thumb_shape") shape = helpers.union([shape, thumb_shape]) thumb_connector_shape = thumb_connectors(side=side) shape = helpers.union([shape, thumb_connector_shape]) if debug_exports: - helpers.export_file(shape=shape, fname=path.join(r"..", "things", r"debug_thumb_connector_shape")) + export_file(shape=shape, part_name=r"debug_thumb_connector_shape") walls_shape = case_walls(side=side) if debug_exports: - helpers.export_file(shape=walls_shape, fname=path.join(r"..", "things", r"debug_walls_shape")) + export_file(shape=walls_shape, part_name=r"debug_walls_shape") s2 = helpers.union([walls_shape]) s2 = helpers.union([s2, *screw_insert_outers(side=side)]) @@ -3881,12 +3881,12 @@ def model_side(side="right"): tbprecut, tb, tbcutout, sensor, ball = generate_trackball_in_wall() shape = helpers.difference(shape, [tbprecut]) - # helpers.export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_1")) + # export_file(shape=shape, part_name=r"_test_1") shape = helpers.union([shape, tb]) - # helpers.export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_2")) + # export_file(shape=shape, part_name=r"_test_2") shape = helpers.difference(shape, [tbcutout]) - # helpers.export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_3a")) - # helpers.export_file(shape=helpers.add([shape, sensor]), fname=path.join(save_path, config_name + r"_test_3b")) + # export_file(shape=shape, part_name=r"_test_3a") + # export_file(shape=helpers.add([shape, sensor]), part_name=r"_test_3b") shape = helpers.union([shape, sensor]) if shape_config['show_caps']: @@ -3896,12 +3896,12 @@ def model_side(side="right"): tbprecut, tb, tbcutout, sensor, ball = generate_trackball_in_cluster() shape = helpers.difference(shape, [tbprecut]) - # helpers.export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_1")) + # export_file(shape=shape, part_name=r"_test_1") shape = helpers.union([shape, tb]) - # helpers.export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_2")) + # export_file(shape=shape, part_name=r"_test_2") shape = helpers.difference(shape, [tbcutout]) - # helpers.export_file(shape=shape, fname=path.join(save_path, config_name + r"_test_3a")) - # helpers.export_file(shape=helpers.add([shape, sensor]), fname=path.join(save_path, config_name + r"_test_3b")) + # export_file(shape=shape, part_name=r"_test_3a") + # export_file(shape=helpers.add([shape, sensor]), part_name=r"_test_3b") shape = helpers.union([shape, sensor]) if shape_config['show_caps']: @@ -4007,48 +4007,45 @@ def baseplate(wedge_angle=None, side='right'): return sl.projection(cut=True)(shape) +def export_file(shape, part_name): + helpers.export_file(shape=shape, fname=path.join(save_path, shape_config['config_name'] + '_' + part_name)) + def run(opts): setup(opts) mod_r = model_side(side="right") - helpers.export_file(shape=mod_r, fname=path.join(save_path, opts['config']['name'] + r"_right")) + export_file(shape=mod_r, part_name=r"right") base = baseplate(side='right') - helpers.export_file(shape=base, fname=path.join(save_path, opts['config']['name'] + r"_right_plate")) - helpers.export_dxf(shape=base, fname=path.join(save_path, opts['config']['name'] + r"_right_plate")) + export_file(shape=base, part_name=r"right_plate") + helpers.export_dxf(shape=base, part_name=r"right_plate") if shape_config['symmetry'] == "asymmetric": mod_l = model_side(side="left") - helpers.export_file(shape=mod_l, fname=path.join(save_path, opts['config']['name'] + r"_left")) + export_file(shape=mod_l, part_name=r"left") base_l = helpers.mirror(baseplate(side='left'), 'YZ') - helpers.export_file(shape=base_l, fname=path.join(save_path, opts['config']['name'] + r"_left_plate")) - helpers.export_dxf(shape=base_l, fname=path.join(save_path, opts['config']['name'] + r"_left_plate")) + export_file(shape=base_l, part_name=r"left_plate") + helpers.export_dxf(shape=base_l, part_name=r"left_plate") else: - helpers.export_file(shape=helpers.mirror(mod_r, 'YZ'), fname=path.join(save_path, opts['config']['name'] + r"_left")) + export_file(shape=helpers.mirror(mod_r, 'YZ'), part_name=r"left") lbase = helpers.mirror(base, 'YZ') - helpers.export_file(shape=lbase, fname=path.join(save_path, opts['config']['name'] + r"_left_plate")) - helpers.export_dxf(shape=lbase, fname=path.join(save_path, opts['config']['name'] + r"_left_plate")) - + export_file(shape=lbase, part_name=r"left_plate") + helpers.export_dxf(shape=lbase, part_name=r"left_plate") if shape_config['oled_mount_type'] == 'UNDERCUT': - helpers.export_file(shape=oled_undercut_mount_frame()[1], fname=path.join(save_path, opts['config']['name'] + r"_oled_undercut_test")) + export_file(shape=oled_undercut_mount_frame()[1], part_name=r"oled_undercut_test") if shape_config['oled_mount_type'] == 'SLIDING': - helpers.export_file(shape=oled_sliding_mount_frame()[1], fname=path.join(save_path, opts['config']['name'] + r"_oled_sliding_test")) + export_file(shape=oled_sliding_mount_frame()[1], part_name=r"oled_sliding_test") if shape_config['oled_mount_type'] == 'CLIP': oled_mount_location_xyz = (0.0, 0.0, -shape_config['oled_mount_depth'] / 2) oled_mount_rotation_xyz = (0.0, 0.0, 0.0) - helpers.export_file(shape=oled_clip(), fname=path.join(save_path, opts['config']['name'] + r"_oled_clip")) - helpers.export_file(shape=oled_clip_mount_frame()[1], - fname=path.join(save_path, opts['config']['name'] + r"_oled_clip_test")) - helpers.export_file(shape=helpers.union((oled_clip_mount_frame()[1], oled_clip())), - fname=path.join(save_path, opts['config']['name'] + r"_oled_clip_assy_test")) - -# base = baseplate() -# helpers.export_file(shape=base, fname=path.join(save_path, opts['config']['name'] + r"_plate")) + export_file(shape=oled_clip(), part_name=r"oled_clip") + export_file(shape=oled_clip_mount_frame()[1], part_name=r"oled_clip_test") + export_file(shape=helpers.union((oled_clip_mount_frame()[1], oled_clip())), part_name=r"oled_clip_assy_test") From fb280783616a9a756dfbd155436c24bb426359d1 Mon Sep 17 00:00:00 2001 From: Edward Date: Tue, 24 Aug 2021 08:52:27 -0400 Subject: [PATCH 09/10] fixed some find/replace errors --- src/dactyl_manuform.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/dactyl_manuform.py b/src/dactyl_manuform.py index d00b8b778..deacdf919 100644 --- a/src/dactyl_manuform.py +++ b/src/dactyl_manuform.py @@ -1,4 +1,3 @@ -from helpers_cadquery import export_file import numpy as np from numpy import pi import math @@ -835,7 +834,7 @@ def thumb_connectors(side='right', style_override=None): def default_thumbcaps(): t1 = default_thumb_1x_layout(sa_cap(1), cap=True) if not shape_config['default_1U_cluster']: - t1.helpers.add(default_thumb_15x_layout(sa_cap(1.5), cap=True)) + t1.add(default_thumb_15x_layout(sa_cap(1.5), cap=True)) return t1 @@ -1127,7 +1126,7 @@ def mini_thumb_15x_layout(shape): def mini_thumbcaps(): t1 = mini_thumb_1x_layout(sa_cap(1)) t15 = mini_thumb_15x_layout(helpers.rotate(sa_cap(1), [0, 0, rad2deg(pi / 2)])) - return t1.helpers.add(t15) + return t1.add(t15) def mini_thumb(side="right"): @@ -1354,7 +1353,7 @@ def minidox_thumb_fx_layout(shape): def minidox_thumbcaps(): t1 = minidox_thumb_1x_layout(sa_cap(1)) - # t1.helpers.add(minidox_thumb_15x_layout(helpers.rotate(sa_cap(1), [0, 0, rad2deg(pi / 2)]))) + # t1.add(minidox_thumb_15x_layout(helpers.rotate(sa_cap(1), [0, 0, rad2deg(pi / 2)]))) return t1 @@ -1553,7 +1552,7 @@ def carbonfet_thumb_15x_layout(shape, plate=True): def carbonfet_thumbcaps(): t1 = carbonfet_thumb_1x_layout(sa_cap(1)) t15 = carbonfet_thumb_15x_layout(helpers.rotate(sa_cap(1.5), [0, 0, rad2deg(pi / 2)])) - return t1.helpers.add(t15) + return t1.add(t15) def carbonfet_thumb(side="right"): @@ -1889,7 +1888,7 @@ def trackball_layout(shape): def tbjs_thumbcaps(): t1 = tbjs_thumb_1x_layout(sa_cap(1)) - # t1.helpers.add(tbjs_thumb_15x_layout(helpers.rotate(sa_cap(1), [0, 0, rad2deg(pi / 2)]))) + # t1.add(tbjs_thumb_15x_layout(helpers.rotate(sa_cap(1), [0, 0, rad2deg(pi / 2)]))) return t1 @@ -3937,7 +3936,7 @@ def baseplate(wedge_angle=None, side='right'): square = cq.Workplane('XY').rect(1000, 1000) for wire in square.wires().objects: - plane = cq.Workplane('XY').helpers.add(cq.Face.makeFromWires(wire)) + plane = cq.Workplane('XY').add(cq.Face.makeFromWires(wire)) shape = helpers.intersect(shape, plane) outside = shape.vertices(cq.DirectionMinMaxSelector(cq.Vector(1, 0, 0), True)).objects[0] @@ -3961,11 +3960,11 @@ def baseplate(wedge_angle=None, side='right'): debugprint(sizes) inner_wire = base_wires[inner_index] - # inner_plate = cq.Workplane('XY').helpers.add(cq.Face.makeFromWires(inner_wire)) + # inner_plate = cq.Workplane('XY').add(cq.Face.makeFromWires(inner_wire)) if wedge_angle is not None: - cq.Workplane('XY').helpers.add(cq.Solid.revolve(outerWire, innerWires, angleDegrees, axisStart, axisEnd)) + cq.Workplane('XY').add(cq.Solid.revolve(outerWire, innerWires, angleDegrees, axisStart, axisEnd)) else: - inner_shape = cq.Workplane('XY').helpers.add(cq.Solid.extrudeLinear(outerWire=inner_wire, innerWires=[], vecNormal=cq.Vector(0, 0, shape_config['base_thickness']))) + inner_shape = cq.Workplane('XY').add(cq.Solid.extrudeLinear(outerWire=inner_wire, innerWires=[], vecNormal=cq.Vector(0, 0, shape_config['base_thickness']))) inner_shape = helpers.translate(inner_shape, (0, 0, -shape_config['base_rim_thickness'])) holes = [] @@ -3974,7 +3973,7 @@ def baseplate(wedge_angle=None, side='right'): holes.append(base_wires[i]) cutout = [*holes, inner_wire] - shape = cq.Workplane('XY').helpers.add(cq.Solid.extrudeLinear(outer_wire, cutout, cq.Vector(0, 0, shape_config['base_rim_thickness']))) + shape = cq.Workplane('XY').add(cq.Solid.extrudeLinear(outer_wire, cutout, cq.Vector(0, 0, shape_config['base_rim_thickness']))) hole_shapes=[] for hole in holes: loc = hole.Center() @@ -4010,6 +4009,9 @@ def baseplate(wedge_angle=None, side='right'): def export_file(shape, part_name): helpers.export_file(shape=shape, fname=path.join(save_path, shape_config['config_name'] + '_' + part_name)) +def export_dxf(shape, part_name): + helpers.export_file(shape=shape, fname=path.join(save_path, shape_config['config_name'] + '_' + part_name)) + def run(opts): setup(opts) @@ -4018,7 +4020,7 @@ def run(opts): base = baseplate(side='right') export_file(shape=base, part_name=r"right_plate") - helpers.export_dxf(shape=base, part_name=r"right_plate") + export_dxf(shape=base, part_name=r"right_plate") if shape_config['symmetry'] == "asymmetric": mod_l = model_side(side="left") @@ -4026,14 +4028,14 @@ def run(opts): base_l = helpers.mirror(baseplate(side='left'), 'YZ') export_file(shape=base_l, part_name=r"left_plate") - helpers.export_dxf(shape=base_l, part_name=r"left_plate") + export_dxf(shape=base_l, part_name=r"left_plate") else: export_file(shape=helpers.mirror(mod_r, 'YZ'), part_name=r"left") lbase = helpers.mirror(base, 'YZ') export_file(shape=lbase, part_name=r"left_plate") - helpers.export_dxf(shape=lbase, part_name=r"left_plate") + export_dxf(shape=lbase, part_name=r"left_plate") From 2b20f5798f2d27cdb6ad5f9fc3f25ffa6c4562c1 Mon Sep 17 00:00:00 2001 From: Edward Date: Tue, 24 Aug 2021 08:59:24 -0400 Subject: [PATCH 10/10] ignore 'things' output is subdirectories --- .gitignore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 6cc67ea9b..3ad3bd062 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,6 @@ debug_* */__pycache__/* *~$* -things/*.scad -things/*.step -things/*.stl \ No newline at end of file +things/**/*.scad +things/**/*.step +things/**/*.stl \ No newline at end of file