import bpy
## Z
class MirrorZ(bpy.types.Operator):
"""Turn ON / OFF Mirror"""
bl_idname = "button.z_operator"
bl_label = "z"
def execute(self, context):
bpy.context.object.use_mesh_mirror_z = False
bpy.context.object.use_mesh_mirror_z = True
return {'FINISHED'}
#############################################################################
#UiPanel2
class UiPanel2(bpy.types.Panel):
"""Creates a Panel in the scene context of the properties editor"""
bl_label = "Mirror"
bl_idname = "OBJECT_PT_panel2"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'Xo'
bl_parent_id = 'OBJECT_PT_panel'
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
row = layout.row()
row.scale_x = 0.35
row.operator("button.z_operator", text = "Z")
def register():
bpy.utils.register_class(MirrorZ)
bpy.utils.register_class(UiPanel2)
def unregister():
bpy.utils.unregister_class(MirrorZ)
bpy.utils.unregister_class(UiPanel2)
if __name__ == "__main__":
register()
Welcome to BA
To toggle a Boolean, do this:
bpy.context.object.use_mesh_mirror_z = not bpy.context.object.use_mesh_mirror_z
1 Like
It works! Thanks!~
1 Like