#!BPY """ Name: 'LapTopNumPad' Blender: 241 Group: 'System' Tooltip: 'Virtual Laptop Numpad' """ __author__ = "Trevor Noble" __version__ = "0.0.1" __bpydoc__ = """\ LapTopNumPad.py 0.0.1 This script allows easy blending on laptops that do not support a USB numpad to co-exist with a fully QWERTY keybord such (e.g. Sony VAIO). Use SHIFT and CTRL keys modifiers as with a normal Num Pad. Thanks to Ray Badstibner (AKA raymaxbad) for creating the BpKeyboard.py script which I canabalised. """ #--------import modules-------- import Blender from Blender import Window, Text, Draw, BGL from Blender.Window import * from Blender.Text import * from Blender.Draw import * from Blender.BGL import * #--------do it-------- def go_short(): QHandle(id) Window.RedrawAll() #--------get 3d window-------- try: # get 3d area area = Window.GetScreenInfo(Window.Types.VIEW3D, rect='total') id = area[0]['id'] # get the first view id except: # get text area area = Window.GetScreenInfo(Window.Types.TEXT) id = area[1]['id'] # get the second text id #--------create buttons-------- def draw(): global PushButton15, PushButton16, PushButton17, PushButton18, PushButton19, PushButton20, PushButton21, PushButton22, PushButton24, PushButton25, PushButton26 glClearColor(0.000, 0.000, 0.000, 0.0) glClear(GL_COLOR_BUFFER_BIT) PushButton('Top', 21, 2, 250, 60, 20, '+SHIFT Bottom View') PushButton('Front', 15, 2, 225, 60, 20, '+SHIFT Back View') PushButton('Right', 17, 2, 200, 60, 20, '+SHIFT Left View') PushButton('8', 22, 23, 171, 20, 20, 'Tilt Up') PushButton('4', 18, 2, 150, 20, 20, 'Pan <') PushButton('5', 19, 23, 150, 20, 20, 'Ortho / Persp') PushButton('6', 20, 44, 150, 20, 20, 'Pan >') PushButton('2', 16, 23, 130, 20, 20, 'Tilt Down') PushButton('0', 24, 2, 100, 20, 20, 'Camera') PushButton('-', 25, 23, 100, 20, 20, 'Plus') PushButton('+', 26, 44, 100, 20, 20, 'Minus') #--------exit function-------- def event(evt, val): if (evt== QKEY and not val): SetKeyQualifiers(0) Exit() #--------button events-------- def bevent(evt): global letter if evt == 69: #DelKey QAdd(id, DELKEY, 1) QAdd(id, DELKEY, 0) go_short() elif evt == 10: #EscPushButton Exit() elif evt == 15: #1PushButton QAdd(id, PAD1, 1) QAdd(id, PAD1, 0) go_short() elif evt == 16: #2PushButton QAdd(id, PAD2, 1) QAdd(id, PAD2, 0) go_short() elif evt == 17: #3PushButton QAdd(id, PAD3, 1) QAdd(id, PAD3, 0) go_short() elif evt == 18: #4PushButton QAdd(id, PAD4, 1) QAdd(id, PAD4, 0) go_short() elif evt == 19: #5PushButton QAdd(id, PAD5, 1) QAdd(id, PAD5, 0) go_short() elif evt == 20: #6PushButton QAdd(id, PAD6, 1) QAdd(id, PAD6, 0) go_short() elif evt == 21: #7PushButton QAdd(id, PAD7, 1) QAdd(id, PAD7, 0) go_short() elif evt == 22: #8PushButton QAdd(id, PAD8, 1) QAdd(id, PAD8, 0) go_short() elif evt == 23: #9PushButton QAdd(id, PAD9, 1) QAdd(id, PAD9, 0) go_short() elif evt == 24: #0PushButton QAdd(id, PAD0, 1) QAdd(id, PAD0, 0) go_short() elif evt == 25: #-PushButton QAdd(id, PADMINUS, 1) QAdd(id, PADMINUS, 0) go_short() elif evt == 26: #=PushButton QAdd(id, PADPLUSKEY, 1) QAdd(id, PADPLUSKEY, 0) go_short() elif evt == 62: #.PushButton QAdd(id, PADPERIOD, 1) QAdd(id, PADPERIOD, 0) go_short() elif evt == 63: #/PushButton QAdd(id, PADSLASHKEY, 1) QAdd(id, PADSLASHKEY, 0) go_short() #--------redraw the window-------- Window.RedrawAll() #--------register the 3 events-------- Register(draw, event, bevent)