Merge pull request #22 from wilderjds/scene-import

Scene import
plate-64p
Kirpal Demian 8 years ago committed by GitHub
commit 4e80dc0f41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      README.md
  2. 32
      import_keyboard.py

@ -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.

@ -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,17 @@ def read(filepath):
empty.select = True
bpy.ops.object.delete(use_global=False)
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")
# 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 +1347,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

Loading…
Cancel
Save