first python coding: toggle wire display for entire scene

Hi all,

I’m trying to write my first python script in blender 2.73,
and all I want it to do is to toggle the “wireframe over solid mesh” display
for all the objects in the scene at once…

currently blender is able to toggle “wireframe-over-solid” display only on one mesh at a time,
which is really annoying. I’d love to have a small addon that just toggles it on or off for the
entire scene at once. (like in Maya :stuck_out_tongue: )

I’ve messed around with the python coding in blender a bit,
(using functions like “bpy.context.object.show_wire=True”)
and while I was partly sucessful on a per-object basis, I’m having no real luck getting it to work for the whole scene at once. :frowning:

any help or advice will be highly appreciated. thanks!

-G

This could be the core code:

import bpy

ob = bpy.context.object
obs = bpy.context.scene.objects


if ob is None:
    for o in obs:
        if o.type == 'MESH':
            ob = o
            break


if ob is not None:
    show_wire = not ob.show_wire
    for ob in obs:
        if ob.type == 'MESH':
            ob.show_wire = show_wire

See here for how to make this an addon with keybinding:
http://www.blender.org/api/blender_python_api_2_73a_release/info_tutorial_addon.html

thanks man! that works very nicely! I added a couple of lines to also display all the edges… on line 15 and 22 :smiley: now all I need is a snappy little UI to go with this…


thanks again. :slight_smile:

cheers!
-G