From 310fe129b3743d9092788d5b8efe813d1fbcc1cd Mon Sep 17 00:00:00 2001 From: jacopods Date: Tue, 13 Feb 2018 17:22:30 -0500 Subject: [PATCH 1/3] Center, rotate the keyboard forward and scale to reasonable size --- import_keyboard.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/import_keyboard.py b/import_keyboard.py index b387a2c..1fc9776 100644 --- a/import_keyboard.py +++ b/import_keyboard.py @@ -456,6 +456,12 @@ def read(filepath): scn = bpy.context.scene scn.display_settings.display_device = "None" + bpy.ops.group.create(name="Keyboard") + + keyboard_empty = bpy.data.objects.new("Keyboard_whole", None) + keyboard_empty.location = (0,0,0) + scn.objects.link(keyboard_empty) + # set width and height of keyboard width = 0 height = 0 @@ -1224,6 +1230,16 @@ def read(filepath): empty.select = True bpy.ops.object.delete(use_global=False) + new_obj_tl.select = True + new_switch.select = True + + scn.objects.active = keyboard_empty + bpy.ops.object.parent_set(type="OBJECT") + + # deselect everything + for obj in scn.objects: + obj.select = False + # set the keyboard width and height if it was smaller than the # current width if key["x"] + key["w"] + 0.05 > width: @@ -1330,10 +1346,25 @@ def read(filepath): bpy.ops.object.join() # name the case side5.name = "Case" + + scn.objects.active = keyboard_empty + bpy.ops.object.parent_set(type="OBJECT") + + # This assumes 1 blender unit = 10cm + blender_scaling = .1905 + keyboard_empty.scale = (blender_scaling,blender_scaling,blender_scaling) + keyboard_empty.rotation_euler[2] = pi + keyboard_empty.location = (-blender_scaling*width*0.5,blender_scaling*height*0.5,blender_scaling*0.5) + # deselect everything for obj in scn.objects: obj.select = False + keyboard_empty.select = True + scn.objects.active = keyboard_empty + bpy.ops.object.transform_apply(location=True, scale=True, rotation=True) + bpy.ops.object.delete(use_global=False) + side5.select = True scn.objects.active = side5 # bevel the corners From b864b1c4f9cd33117b19dd2a47b057260ff6648b Mon Sep 17 00:00:00 2001 From: jacopods Date: Sun, 18 Feb 2018 02:03:37 -0500 Subject: [PATCH 2/3] Add link to scene in the readme file --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 32f2b18..fcfc387 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,9 @@ Allows you to import keyboard layouts into blender and have them render in 3d + To make the keycap legends backlit, make the legend color the same as whatever color you made the LEDs +### Blender scene file +A basic scene for blender can be found in [this gist](https://gist.github.com/wilderjds/5e43cc04f202fe71c51f69e4775a3c4e). Open the scene in blender before importing. Please note that lighting, camera and render setup will most probably require some tweaking to fit with your specific layout. + ### Contributions Special thanks to [@zslane](https://deskthority.net/zslane-u8694/) on Deskthority for the SA models. From 741da49b155e268977123b75d934e11fe3cdbd76 Mon Sep 17 00:00:00 2001 From: jacopods Date: Wed, 28 Feb 2018 23:50:40 -0500 Subject: [PATCH 3/3] Add also LEDs to the keyboard empty for scaling --- import_keyboard.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/import_keyboard.py b/import_keyboard.py index 1fc9776..0bc60dd 100644 --- a/import_keyboard.py +++ b/import_keyboard.py @@ -1232,7 +1232,8 @@ def read(filepath): new_obj_tl.select = True new_switch.select = True - + if "led" in keyboard: + new_led.select = True scn.objects.active = keyboard_empty bpy.ops.object.parent_set(type="OBJECT")