Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- class ShowWirerame(bpy.types.Operator):
- bl_idname = "show_wireframe.operator"
- bl_label = "Show wireframe"
- bl_options = {'REGISTER', 'UNDO'}
- @classmethod
- def poll(cls, context):
- return context.active_object is not None
- def execute(self, context):
- active_object = context.active_object # Store active object
- for obj in context.selected_objects:
- context.view_layer.objects.active = obj
- obj.show_wire = True
- obj.show_all_edges = True
- context.view_layer.objects.active = active_object # Restore active object
- return {'FINISHED'}
- class HideWirerame(bpy.types.Operator):
- bl_idname = "hide_wireframe.operator"
- bl_label = "Hide Wirerame"
- bl_options = {'REGISTER', 'UNDO'}
- @classmethod
- def poll(cls, context):
- return context.active_object is not None
- def execute(self, context):
- active_object = context.active_object # Store active object
- for obj in context.selected_objects:
- context.view_layer.objects.active = obj
- obj.show_wire = False
- obj.show_all_edges = False
- context.view_layer.objects.active = active_object # Restore active object
- return {'FINISHED'}
- class VIEW3D_PT_ShowWirerame(bpy.types.Panel):
- bl_label = "Show Wirerame"
- bl_category = "Show Wirerame"
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'UI'
- def draw(self, context):
- layout = self.layout
- layout.operator("show_wireframe.operator")
- layout.operator("hide_wireframe.operator")
- def register():
- bpy.utils.register_class(VIEW3D_PT_ShowWirerame)
- bpy.utils.register_class(ShowWirerame)
- bpy.utils.register_class(HideWirerame)
- def unregister():
- bpy.utils.unregister_class(VIEW3D_PT_ShowWirerame)
- bpy.utils.unregister_class(ShowWirerame)
- bpy.utils.unregister_class(HideWirerame)
- if __name__ == "__main__":
- register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement