Paste Code
Paste Blends
Paste Images
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

# <pep8-80 compliant>

# Copyright (C) 2013-2014: Tomas Dostal (stanley82), tomas.dostal.cz@gmail.com

bl_info = {
"name": "Wireframe On Shaded Switch",
"description": "Toggle wireframe on shaded display method for all object in scene",
"author": "Tomas Dostal (stanley82)",
"version": (0, 1),
"blender": (2, 7, 0),
"location": "View3D > Object",
"warning": "WIP - not final version!",
"tracker_url": "",
"support": "COMMUNITY",
"category": "Object"}

import bpy

def toggleWire():
s = bpy.context.scene
for object in s.objects:
if object.type == 'MESH':
if not object.show_wire or not object.show_all_edges:
object.show_wire = True
object.show_all_edges = True
print (object.name)
else:
object.show_wire = False
object.show_all_edges = False
print (object.name)

class ToggleWire (bpy.types.Operator):
"""Toggle wire on all meshes"""
bl_label = "Toggle wire"
bl_idname ="object.toggle_wire"
bl_options = {'REGISTER', 'UNDO'}

def execute(self,context):
print ('Toggling Wire...')
toggleWire()
return {'FINISHED'}

def draw_ui(self,context):
self.layout.operator(ToggleWire.bl_idname, text="Toggle wire")

def register():
bpy.utils.register_class (ToggleWire)
bpy.types.VIEW3D_MT_object.append(draw_ui)

def unregister():
bpy.utils.unregister_class (ToggleWire)
bpy.types.VIEW3D_MT_object.remove(draw_ui)

if __name__ == "__name__":
register()
  1. # ##### BEGIN GPL LICENSE BLOCK #####
  2. #
  3. #  This program is free software; you can redistribute it and/or
  4. #  modify it under the terms of the GNU General Public License
  5. #  as published by the Free Software Foundation; either version 2
  6. #  of the License, or (at your option) any later version.
  7. #
  8. #  This program is distributed in the hope that it will be useful,
  9. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11. #  GNU General Public License for more details.
  12. #
  13. #  You should have received a copy of the GNU General Public License
  14. #  along with this program; if not, write to the Free Software Foundation,
  15. #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. #
  17. # ##### END GPL LICENSE BLOCK #####
  18.  
  19. # <pep8-80 compliant>
  20.  
  21. # Copyright (C) 2013-2014: Tomas Dostal (stanley82), tomas.dostal.cz@gmail.com
  22.  
  23. bl_info = {
  24.     "name": "Wireframe On Shaded Switch",
  25.     "description": "Toggle wireframe on shaded display method for all object in scene",
  26.     "author": "Tomas Dostal (stanley82)",
  27.     "version": (0, 1),
  28.     "blender": (2, 7, 0),
  29.     "location": "View3D > Object",
  30.     "warning": "WIP - not final version!",
  31.     "tracker_url": "",
  32.     "support": "COMMUNITY",
  33.     "category": "Object"}
  34.  
  35. import bpy
  36.  
  37. def toggleWire():
  38.     s = bpy.context.scene
  39.     for object in s.objects:
  40.         if object.type == 'MESH':
  41.             if not object.show_wire or not object.show_all_edges:
  42.                 object.show_wire = True
  43.                 object.show_all_edges = True
  44.                 print (object.name)
  45.             else:
  46.                 object.show_wire = False
  47.                 object.show_all_edges = False
  48.                 print (object.name)
  49.                
  50. class ToggleWire (bpy.types.Operator):
  51.     """Toggle wire on all meshes"""
  52.     bl_label = "Toggle wire"
  53.     bl_idname ="object.toggle_wire"
  54.     bl_options = {'REGISTER', 'UNDO'}
  55.  
  56.     def execute(self,context):
  57.         print ('Toggling Wire...')
  58.         toggleWire()
  59.         return {'FINISHED'}
  60.  
  61. def draw_ui(self,context):
  62.     self.layout.operator(ToggleWire.bl_idname, text="Toggle wire")    
  63.  
  64. def register():
  65.     bpy.utils.register_class (ToggleWire)
  66.     bpy.types.VIEW3D_MT_object.append(draw_ui)
  67.  
  68. def unregister():
  69.     bpy.utils.unregister_class (ToggleWire)
  70.     bpy.types.VIEW3D_MT_object.remove(draw_ui)
  71.  
  72. if __name__ == "__name__":
  73.     register()
go to heaven