I wrote a simple script to change the state of the 3d manipulator in Blender 2.5 (to allow all you freaks to make Max/Maya/C4d/etc.-like keybindings of it).
Just copy the following code to a file called manipulator(or anything).py and put it in your .blender/scripts/op/-folder:
import bpy
class ToggleManipulatorMode(bpy.types.Operator):
'''Changes the maipulator mode'''
bl_idname = "view3d.manipulator_mode"
bl_label = "Toggle Manipulator Mode"
bl_register = False
bl_undo = False
tool = bpy.props.IntProperty(name="Tool",default=1,min=1,max=3)
additive = bpy.props.BoolProperty(name="Additive",default=False)
def poll(self, context):
return context.space_data.type == "VIEW_3D"
def execute(self, context):
context.space_data.manipulator=True
if self.properties.additive == False:
context.space_data.manipulator_translate=False
context.space_data.manipulator_rotate=False
context.space_data.manipulator_scale=False
if self.properties.tool == 1:
context.space_data.manipulator_translate=True
if self.properties.tool == 2:
context.space_data.manipulator_rotate=True
if self.properties.tool == 3:
context.space_data.manipulator_scale=True
return ('FINISHED',)
bpy.ops.add(ToggleManipulatorMode)
if __name__ == "__main__":
bpy.ops.view3d.manipulator_mode
Then start blender and run the code below from a text editor. Now if you open the user preferences, select the “View3D”-keymap, press edit and scroll to the bottom you should see three new entries. You can map these to whatever you want (NOTE: for some strange reason you will have to expand the items and select “PRESS” from the menu to the left of the checkboxes foor them to work).
I solved the problem. Some hotkeys are identical with other hotkeys, for example E = Extrude. When I changed, it worked. Thanks again because I am an old Maya user. :yes:
vidar_nelson: very interesting script. Would you mind if I added a link to your post in the thread on scripting examples for 2.5?
It is a nice introduction to adding custom functions to the keymap.
Sure, go ahead.
Although hopefully in the final 2.6 release you will not have to use the second script at all, at the moment it’s just a workaround since you can’t define settings for the properties if you add entries to the keymap by hand.
You don’t really need a python operator for that, just use the wm.context_toggle operator, like this. Just make sure you add that to the View3D keymap, then you’re sure that it will only be called when a view3d is in context.
Note: The context attribute value is “space_data.occlude_geometry” but the button is not wide enough to show all of it.
As far as your python code though, you can change the exec function for this:
context.space_data.occlude_geometry = not context.space_data.occlude_geometry
I’m on a 32bit system, but I don’t think that makes a difference.
It’s a bit hard to say what is going wrong for you. Do you get any error messages, or does it simply look like nothing changes?
For clarity, these are the steps I take to get vidar_nelson’s script to work in Blender 2.5 alpha 0:
Copy/paste the first codeblock (the one with the ToggleManipulatorMode class) into Blender and run it once (alt+P)
Copy/paste the second codeblock into Blender and run it once (alt+P)
Go to the User Preferences window and choose as Map: View3D
Press the Edit button and scroll to the bottom
Expand the last three items (they’re called view3d.manipulator_mode)
Next to the hotkey letter (Q, W or E) there is a popup box. For each of the three items, pick ‘Press’
Done. Select an object in the 3d-view and you can now change manipulator mode by pressing the Q/W/E buttons on your keyboard.
milan981: In your video you go wrong at 01:20. You shouldn’t quit Blender in between. Just go directly to the user preferences and it will show up over there. Do no start a new instance of Blender.
If you wish the new hotkeys to work every time you start Blender, you need to save them to the default file, after all the other steps you’ve taken (so after you got the hotkeys working).