Simple script to enter modes

Hi,

I would like to know how to make a simple script to change modes with the tab hotkey.
I would add Object/Edit/Sculpt to a custom menu when I press Tab like this picture.


I d’ont find the good command to do that.

I don’t find the command to show the wire too, so If you know, plz help me :wink:

Thank you !

Ced

I found alternate pie who work’s very well !

http://www.blenderartists.org/forum/showthread.php?317916-An-alternative-to-pies

I have too many bugs with the pie menu addon, so this one is great !

Hi, I would like to add some features to my menu like wireframe On/Off, xray, but I don’t find the good command.


Can you help me for this plz ?

That’s because object.show_x_ray and object.show_wire are not operators but properties.

For properties you do something like

col.prop(obj, "show_wire", text="Wire")

If I put this, I don’t have button with wire on the menu.

col.operator("wm.context_toggle", text="Xray").data_path = "object.show_x_ray"
col.operator("wm.context_toggle", text="Wire").data_path = "object.show_wire"

That’s work ! thank’s !

Another question !

A friend of mine would like to put the wire and draw all edges on hotkeys, so I did this.


It’s ok, but he want’s to add the wire on all objects on the scene.
I would like to do this on my menu too.

Do you know how to do this ?

you’d have to add a new operator for that, something like this:


import bpy

class AllWires(bpy.types.Operator):
    '''Turn on wires for all objects'''
    bl_idname = "object.all_wires"
    bl_label = "Wires - All objects"
    bl_options = {'REGISTER', 'UNDO'}

    @classmethod
    def poll(cls, context):
        return len(bpy.context.scene.objects)>0

    def execute(self, context):
        for object in bpy.context.scene.objects :
            if object.type == 'MESH':
                object.show_wire = True
        return {'FINISHED'}


def register():
    bpy.utils.register_class(AllWires)


def unregister():
    bpy.utils.unregister_class(AllWires)


if __name__ == "__main__":
    register()

    # test call
    bpy.ops.object.all_wires()

Of course, this only turns the wires on, it doesn’t toggle them. It’s up to you to add the logic for that :slight_smile:

Ok, I see, I’m trying to do that in my custom popup menu !