#!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, 251, 83, 20, '+SHIFT Bottom View') PushButton('Front', 15, 2, 231, 83, 20, '+SHIFT Back View') PushButton('Right', 17, 2, 211, 83, 20, '+SHIFT Left View') PushButton('/', 63, 2, 191, 42, 20, 'Enter / Leave Local View') PushButton('*', 27, 44, 191, 20, 20, 'Rotate View to Object Orientation') PushButton('-', 25, 64, 171, 20, 40, 'Zoom Out') PushButton('+', 26, 64, 111, 20, 60, 'Zoom In') PushButton('7', 21, 2, 171, 20, 20, 'Top View | Click while pressing SHIFT for Bottom View') PushButton('8', 22, 23, 171, 20, 20, 'Tilt Up') PushButton('9', 23, 44, 171, 20, 20, 'Force Redraw/Recalculation') PushButton('4', 18, 2, 151, 20, 20, 'Pan <') PushButton('5', 19, 23, 151, 20, 20, 'Toggle Orthogonal / Perspective View') PushButton('6', 20, 44, 151, 20, 20, 'Pan >') PushButton('1', 15, 2, 131, 20, 20, 'Front View | Click while pressing SHIFT for Back View') PushButton('2', 16, 23, 131, 20, 20, 'Tilt Down') PushButton('3', 17, 44, 131, 20, 20, 'Side View: Right | Click while pressing SHIFT for Side View: Left') PushButton('0', 24, 2, 111, 42, 20, 'View from Active Camera | Hold CTRL to Set Active Camera') PushButton('.', 62, 44, 111, 20, 20, 'Center View Around Selection') PushButton('EXIT', 10, 2, 91, 83, 20, 'Q or ESC KEY to Exit') #--------exit function-------- def event(evt, val): if (evt== QKEY and not val) or evt == ESCKEY: 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 == 100: #EXIT Exit() 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 == 27: #=PushButton QAdd(id, PADASTERKEY, 1) QAdd(id, PADASTERKEY, 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)