From d24e5b2847300e24149156146c7212ca9aebee2d Mon Sep 17 00:00:00 2001 From: Joshua Shreve Date: Fri, 13 Aug 2021 17:11:44 -0400 Subject: very interim commit to check tbiw issues. --- src/dactyl_manuform.py | 40 +++++++++++++++++++++++++++++++++------- src/generate_configuration.py | 17 +++++++++++++---- src/helpers_blender.py | 14 +++++++++++--- src/run_config.json | 4 ++-- 4 files changed, 59 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/dactyl_manuform.py b/src/dactyl_manuform.py index 666e890..13be96c 100644 --- a/src/dactyl_manuform.py +++ b/src/dactyl_manuform.py @@ -1719,18 +1719,34 @@ def carbonfet_thumb_connectors(): # Trackball (Ball + 4-key) THUMB CLUSTER ############################ +def trackball_thumb_position_rotation(): + rot = [10, -15, 5] + pos = thumborigin() + shift = [-42, -20, -5] + for i in range(len(pos)): + pos[i] = pos[i] + shift[i] + return pos, rot + + def trackball_place(shape): - shape = rotate(shape, [10, -15, 5]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-42, -20, -5]) + pos, rot = trackball_thumb_position_rotation() + shape = rotate(shape, rot) + shape = translate(shape, pos) return shape def trackball_thumb_tl_place(shape): debugprint('thumb_tr_place()') + # Modifying to make a "ring" of keys + + shape = translate(shape, (0, )) shape = rotate(shape, [5, 10, -65]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-14, -9, 0]) + + # shape = rotate(shape, [5, 10, -65]) + # shape = translate(shape, thumborigin()) + # shape = translate(shape, [-14, -9, 0]) + + return shape def trackball_thumb_mr_place(shape): @@ -2866,8 +2882,7 @@ def external_mount_hole(): ) return shape -def generate_trackball_in_wall(): - pos, rot = tbiw_position_rotation() +def generate_trackball(pos, rot): precut = trackball_cutout() precut = rotate(precut, rot) precut = translate(precut, pos) @@ -2896,6 +2911,13 @@ def generate_trackball_in_wall(): # return precut, shape, cutout, ball return precut, shape, cutout, sensor, ball +def generate_trackball_in_cluster(): + + pos, rot = trackball_position_rotation() + return generate_trackball(pos, rot) + + + def tbiw_position_rotation(): base_pt1 = key_position( list(np.array([-mount_width/2, 0, 0]) + np.array([0, (mount_height / 2), 0])), @@ -2921,6 +2943,10 @@ def tbiw_position_rotation(): return tbiw_mount_location_xyz, tbiw_mount_rotation_xyz +def generate_trackball_in_wall(): + pos, rot = tbiw_position_rotation() + return generate_trackball(pos, rot) + def oled_position_rotation(side='right'): diff --git a/src/generate_configuration.py b/src/generate_configuration.py index ba1fb3e..f454d24 100644 --- a/src/generate_configuration.py +++ b/src/generate_configuration.py @@ -7,8 +7,8 @@ r2d = 180 / pi shape_config = { - 'ENGINE': 'solid', # 'solid' = solid python / OpenSCAD, 'cadquery' = cadquery / OpenCascade - # 'ENGINE': 'cadquery', # 'solid' = solid python / OpenSCAD, 'cadquery' = cadquery / OpenCascade + # 'ENGINE': 'solid', # 'solid' = solid python / OpenSCAD, 'cadquery' = cadquery / OpenCascade + 'ENGINE': 'cadquery', # 'solid' = solid python / OpenSCAD, 'cadquery' = cadquery / OpenCascade ###################### @@ -58,9 +58,9 @@ shape_config = { 'thumb_plate_bl_rotation': 0.0, # Bottom right plate rotation tweaks as thumb cluster is crowded for hot swap, etc. ################################### - ## Trackball ## + ## Trackball in Wall ## ################################### - 'trackball_in_wall': False, # Separate trackball option, placing it in the OLED area + 'trackball_in_wall': True, # Separate trackball option, placing it in the OLED area 'tbiw_hole_diameter': 36, 'tbiw_hole_height': 40, 'tbiw_ball_center_row': 0.2, # up from cornerrow instead of down from top @@ -75,6 +75,15 @@ shape_config = { '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 Thumb Cluster ## + ################################### + + + + ################################### + ## Trackball General ## + ################################### 'trackball_Usize': 1.5, # size for inner key near trackball 'trackball_rotation': 0.0, # used to rotate the sensor direction around z. # 'trackball_sensor_rotation': 0.0, # used to rotate the sensor direction around z. diff --git a/src/helpers_blender.py b/src/helpers_blender.py index 470d5e8..86857a3 100644 --- a/src/helpers_blender.py +++ b/src/helpers_blender.py @@ -1,4 +1,12 @@ -import solid as sl +import bpy +import bmesh +import os +import sys +import time +import mathutils +from math import pi, radians, sin, cos +from contextlib import contextmanager + debug_trace = False @@ -7,7 +15,7 @@ def debugprint(info): print(info) def box(width, height, depth): - return sl.cube([width, height, depth], center=True) + return bpy.ops.mesh.primitive_cube_add(size=1, location=(0, 0, 0), scale=(width, height, depth)) def cylinder(radius, height, segments=100): @@ -27,7 +35,7 @@ def rotate(shape, angle): def translate(shape, vector): - return sl.translate(tuple(vector))(shape) + return bpy.ops.transform.translate( def mirror(shape, plane=None): diff --git a/src/run_config.json b/src/run_config.json index a712c6f..4d637c8 100644 --- a/src/run_config.json +++ b/src/run_config.json @@ -1,5 +1,5 @@ { - "ENGINE": "solid", + "ENGINE": "cadquery", "save_dir": ".", "config_name": "DM", "show_caps": false, @@ -29,7 +29,7 @@ "thumb_plate_ml_rotation": 0.0, "thumb_plate_br_rotation": 0.0, "thumb_plate_bl_rotation": 0.0, - "trackball_in_wall": false, + "trackball_in_wall": true, "tbiw_hole_diameter": 36, "tbiw_hole_height": 40, "tbiw_ball_center_row": 0.2, -- cgit v1.2.3