Display Wire for all the objects in the scene

hi guys!

The usual way I turn on the wireframe on the model is to go to properties panel > object > display > Wire.
Wondering Is there any shortcut where I can turn on wireframe for all the objects in the scene.

-sreenivas

Short python script will do, you could wrap it in a small addon and drop a button somewhere:


import bpy;
 
for obj in bpy.data.objects:
    obj.show_wire = True

Should be self explaining.
obj is the iteration variable holding every object in the scene once.
.show_wire is the method to turn on/off wireframes (True/False)

hth.

@ arexma
Yeah! we are on the same page:D. I thought of writing the script myself and later thought there must be something out there which does that and posted here…
so… I came up with this… tried to implement the toggle functionality.
I was just starting on python so feel free to give some comments.

My plan was to assign a shortcut of shift + W but couldn’t figure out how to assign from the addon itself. Any help in that area would be appreciated.

The problem with this addon is the newly created objects won’t have the wireframe turned on. It would be great if we have Something like wireframe on shaded in maya.



import bpy

def main(context):            
    objects_list = [ obj for obj in bpy.data.objects if obj.type in ['MESH']]
    objects_with_wire = [obj for obj in objects_list if obj.show_wire == True]

    if len(objects_with_wire) == 0:
        for ob in objects_list:
            ob.show_wire = True
            ob.show_all_edges = True
    else:
        for ob in objects_with_wire:
            ob.show_wire = False
            ob.show_all_edges = False

class wireframeOnShaded(bpy.types.Operator):
    """ Displays wire frame on shaded with draw all edges"""
    bl_idname = "object.wireframe_on_shaded"
    bl_label = "Wireframe on shaded"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        main(context)
        return {'FINISHED'}

def register():
    bpy.utils.register_class(wireframeOnShaded)
   
def unregister():
    bpy.utils.unregister_class(wireframeOnShaded)
    
if __name__ == "__main__":
    register()


finally figure out how to how to assign the shortcut (shift + W) from the addon itself…


import bpy

def main(context):            
    objects_list = [ obj for obj in bpy.data.objects if obj.type in ['MESH']]
    objects_with_wire = [obj for obj in objects_list if obj.show_wire == True]
    
    if len(objects_with_wire) == 0:
        for ob in objects_list:
            ob.show_wire = ob.show_all_edges = True             
    else:
        for ob in objects_with_wire:
            ob.show_wire = ob.show_all_edges = False            

class wireframeOnShaded(bpy.types.Operator):
    """ Displays wire frame on shaded with draw all edges on all objects"""
    bl_idname = "object.wireframe_on_shaded"
    bl_label = "Wireframe on shaded"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        main(context)
        return {'FINISHED'}

def register():
    bpy.utils.register_class(wireframeOnShaded)
    km = bpy.context.window_manager.keyconfigs.default.keymaps['Object Mode']
    kmi = km.keymap_items.new("object.wireframe_on_shaded", 'W', 'PRESS', shift=True)
   
def unregister():
    bpy.utils.unregister_class(wireframeOnShaded)
    km = bpy.context.window_manager.keyconfigs.default.keymaps['Object Mode']
    for kmi in (kmi for kmi in km.keymap_items if kmi.idname in {"object.wireframe_on_shaded", }):
        km.keymap_items.remove(kmi) 

if __name__ == "__main__":
    register()

1 Like