|
|||||||
![]() |
|
|
Thread Tools |
|
|||
|
For months I have been frustrated by my SonyVAIO inability to allow a USB numpad to coexist with a full QWERTY keyboard map. Then along came Ray Badstibner (AKA raymaxbad) who inspited me with his BpKeyboard.py script. I adapted his work to create the Laptop Numpad Script.
Save it as LapTopNumPad.py Thanks, Trevor Noble #!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) |
|||
|
#1
|
|||
|
|
|
||||
|
Cool idea
![]() I experimented with your script and modified it a bit to contain all the numpad keys, to approximate numpad key layout a little more, and to preserve indentations so the script can be copied and pasted without any problems. Some small changes are in there as well, such as adding ESCKEY detection and a clickable Exit button for the script. Since 1, 3, and 7 keys are back in there, the Top, Front, Right (Side) buttons can optionally come out of the GUI by placing a # character in front of each of those three lines below. I hope these modifications can be helpful ![]() Code:
............................................
www.ArtofInterpretation.com (Blog) ("Recent Images" RSS feed) (Interview on Blender Guru) |
||||
|
#2
|
|
|||
|
Just realised I lost all the indents just pasting the script!!
This means it will throw an error tantrum if you try to run it!You can get it here instead. Feel free to improve it. http://homepage.eircom.net/~3d4free/download/LapTopNumPad.py hope it is useful Regds Trevor |
|||
|
#3
|
|
|||
|
Hi RobertT
Geewhizz you are fast. Thanks for the additional code. Your modifications expand the virtual numpad to its full glory. I will update the link I just posted with your full key version.Appreciate the help Regds Trevor |
|||
|
#4
|
|
||||
|
Haha, thanks
I was browsing the forum while waiting for several hundred frames to render in Blender, so I had some free time and noticed your cool script. I'm glad the changes worked out. RobertT
............................................
www.ArtofInterpretation.com (Blog) ("Recent Images" RSS feed) (Interview on Blender Guru) |
||||
|
#5
|
|
|||
|
New improved Laptop Numpad Script.
http://homepage.eircom.net/~3d4free/download/Laptop_NumPad.py right-click on the link and choose Save As. Copy it to your scripts folder. It will be available as a System menu item. regds Trevor |
|||
|
#6
|
|
|||
|
hi mugwah
I was realy looking forward to trying your script. (as I have frequent misagreements, with my laptop about the interpretation of what I am typing) but It doesn't appear in the menu when I refresh. what version of blender do you use? I have 241 with full python allso installed cheers Smitje |
|||
|
#7
|
|
|||
|
Hi Smitje
Sometimes blender does not register the scripts properly in the menu system (on my PC anyway). You can run any script manually this way: Open a text window and load the script manually with File> Open. Then from the menu, File> Run Python Script, to get it to work. Hope you find it useful Regds T |
|||
|
#8
|
|
|||
|
Thanks that works like a charm
![]() that makes life a lot easier when working on a laptop. good job! Cheers Smitje |
|||
|
#9
|
|
||||
|
When I run the script I get the following error:
I'm using Blender 2.41 w/ Python 2.4 on Windows Traceback (mose recent call last): File "C:\Editing\Blender\.blender\scripts\Laptop_NumPad .py", line 46, in ? id = area[1]['id'] # get the second text id IndexError: list index out of range |
||||
|
#10
|
|
|||
|
Hi Snosoe,
The script needs an open 3D viewport to be available. Split your 3D viewport in two and run the script in the right hand window. This version should be ok http://homepage.eircom.net/~3d4free/...Top_Num_Pad.py cheers T Last edited by mugwah; 07-Jul-06 at 21:31. |
|||
|
#11
|
|
||||
|
Thanks mugwah,
Works great now, thanks for the help and the great script. Snosoe |
||||
|
#12
|
|
|||
|
Hi mugwah
Still love your script. Yesterday I was using it on the train and I had 2 3d views open, but could controll only one. Do you think it would be possible to switch what window the script controlls? cheers Smitje |
|||
|
#13
|
|
||||
|
Thanks very much. still it would be great if there would be a way to redirect blender shortcuts, since this is still about clicking, but really usable for some things(view selected and local view mode). I think that there are still more and more laptopers and the more important shortcuts should be moved to the main keyboard.
|
||||
|
#14
|
|
|||
|
Why don't they instead of emulating the numpad, but remap the numbers.
1 - Top view 2 - Front view 3 - Side view Shift - 1/2/3 for opposite view 4 - Perspective/Othoganal view 5 - View Selected 6 - Isolated view 7 - 8 - 9 - 0 - camera view I don't even use the rotate keys 2,4,6, & 8. What are your views on the emulated numpad option? |
|||
|
#15
|
|
|||
|
Hi smitje.
AFAIK scripts can only affect one dominant 3d window as the mouse pointer has to be over the script window to operate it. Hi CGTiger, You are quite correct. You lose the direct layer keys but you always have the M KEY!! The script is just another way of doing it. What CGtiger is refering to is the 'Emulate Numpad' button in the System & OpenGL part of the Preferences pulldown. That remaps the 1-0 keys for navigation, |
|||
|
#16
|
|
|||
|
I figured out what the problem is with the script not showing up in the Scripts menu:
There's an extra newline at the beginning of the file before the #BSP declaration that prevents Blender from finding it. Simple problem, simple fix. |
|||
|
#17
|
|
|||
|
Thanks raceomazion
Why that script did not show in the scripts menu was was bugging me. Thanks for pointing out the problem! Fixed. |
|||
|
#18
|
|
|||
|
edit
thnx Last edited by xchak; 15-Oct-09 at 02:20. |
|||
|
#19
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VirtualUndo Script - Anyone want to Help? | mthoenes | Python & Plugins | 26 | 12-Nov-06 17:09 |
| NEW: Aligner/Displacer/Randomizer Script | RobertT | Python & Plugins | 19 | 07-Nov-06 16:24 |
| Terragen script generator | mfoxdogg | Python & Plugins | 3 | 01-Jun-06 00:59 |
| New Script List | theeth | Python & Plugins | 28 | 07-Mar-06 00:56 |
| auto UV mapping python script -> speeds up level texturin | lizard809 | Game Engine Support and Discussion | 7 | 25-Mar-03 01:38 |