Hi all,
I’ve made this small add-on that helps with my workflow on transformation. What it does is check if the transform manipulator is hidden or shown and chose to show the manipulator when pressing G/R/S or use the standard Blender behavior. I do this because I love the manipulators while animating/rigging, but I prefer a smooth uncluttered view while modeling.
The add-on was working perfectly until version 2.63, but with 2.64 on (tested on trunk as well), the parameter that I pass to the function to chose which operation to execute, gets wonky after I select the rotate option (t = 2).
To reproduce the problem, assign view3d.transform_plus to G/R/S keymap in the 3d view, and select from the dropdown the correct operation. Now if you hide the manipulator (CTRL+Space) and use the keys, normal Blender behavior is invoked. When you show the manipulator, pressing the key will cycle true grab, rotate, scale except for when you go back to the translate one, in which case it doesn’t work anymore (you can see the print statement returning 2 even if you press G).
Note that if you press R twice with the manipulator on, it’s supposed to be hiding temporarily the manipulator without disabling it.
bl_info = {
'name': 'Transform Plus',
'author': 'Gianmichele Mariani',
'version': (1, 0 ,0),
'blender': (2, 6, 1),
'location': 'Bind the operator to your transform keys ',
'description': 'Interaction model based on manipulator visibility',
'category': '3D View'}
import bpy
def main(context, t):
space = context.space_data
#space.show_manipulator = not space.show_manipulator
print(t)
# Translate
if t=="1":
if space.show_manipulator:
if space.use_manipulator_translate:
bpy.ops.view3d.enable_manipulator('INVOKE_DEFAULT', translate=False, rotate=False, scale=False)
else:
bpy.ops.view3d.enable_manipulator('INVOKE_DEFAULT', translate=True, rotate=False, scale=False)
else:
bpy.ops.transform.translate('INVOKE_DEFAULT')
# Rotate
elif t=="2":
if space.show_manipulator:
if space.use_manipulator_rotate:
bpy.ops.view3d.enable_manipulator('INVOKE_DEFAULT', translate=False, rotate=False, scale=False)
else:
bpy.ops.view3d.enable_manipulator('INVOKE_DEFAULT', translate=False, rotate=True, scale=False)
else:
bpy.ops.transform.rotate('INVOKE_DEFAULT')
# Scale
elif t=="3":
if space.show_manipulator:
if space.use_manipulator_scale:
bpy.ops.view3d.enable_manipulator('INVOKE_DEFAULT', translate=False, rotate=False, scale=False)
else:
bpy.ops.view3d.enable_manipulator('INVOKE_DEFAULT', translate=False, rotate=False, scale=True)
else:
bpy.ops.transform.resize('INVOKE_DEFAULT')
class TransformPlus(bpy.types.Operator):
'''Transform Plus'''
bl_idname = "view3d.transform_plus"
bl_label = "Transform Plus"
values = [ ( "1", "Translate", "Translate" ),
( "2", "Rotate", "Rotate" ),
( "3", "Scale", "Scale" )]
tool = bpy.props.EnumProperty(name="Tool", items=values, description="Choose an operator")
@classmethod
def poll(cls, context):
return context.space_data.type == 'VIEW_3D'
def execute(self, context):
main(context, self.properties.tool)
return{'FINISHED'}
def register():
bpy.utils.register_class(TransformPlus)
def unregister():
bpy.utils.unregister_class(TransformPlus)
if __name__ == "__main__":
register()