import bpy
from bpy.props import StringProperty, IntProperty, BoolProperty
from bpy.types import (
GizmoGroup,
)
# CUTOM PANEL IN PROPERTIES OUTPUT PANEL
class CUSTOM_PT_menupanel(bpy.types.Panel):
"""Creates a Panel in the Output Properties of the properties editor"""
bl_label = "Test"
bl_idname = "SCENE_PT_layout"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "output"
def draw(self, context):
layout = self.layout
scene = context.scene
row = layout.row()
row.prop(scene, "gizmo_show_hide")
#SCREEN OVERLAY GIZMO
class Camera_overlay(GizmoGroup):
bl_idname = "Gizmo_Icon"
bl_label = "Gizmo"
bl_space_type = 'VIEW_3D'
bl_region_type = 'WINDOW'
bl_options = {'PERSISTENT', 'SCALE'}
def draw_prepare(self, context):
region = context.region
self.my_gizmo.matrix_basis[0][3] = region.width - 40
self.my_gizmo.matrix_basis[1][3] = 40
def setup(self, context):
mpr = self.gizmos.new("GIZMO_GT_button_2d")
mpr.icon = 'OUTLINER_OB_CAMERA'
mpr.draw_options = {'BACKDROP', 'OUTLINE'}
self.my_gizmo = mpr
#GIZMO SHOW AND HIDE FUNCTION
def update_func_gizmo(self, context):
areas = context.workspace.screens[0].areas
for area in areas:
for space in area.spaces:
if space.type == 'VIEW_3D':
space.show_gizmo^= True
return{'FINISHED'}
#CHECKBOX GIZMO BOOL
bpy.types.Scene.gizmo_show_hide = BoolProperty(
name="Gizmo Hide",
description="Check Box to Show And Hide Gizmo",
default = True, update = update_func_gizmo)
#CLASS LIST
classes = (
CUSTOM_PT_menupanel,
Camera_overlay,
)
#REGISTER AND UNREGISTER CLASSES
register, unregister = bpy.utils.register_classes_factory(classes)
if __name__ == "__main__":
register()
$\begingroup$
$\endgroup$
1
-
$\begingroup$ I found an answer to my solution after hours of playing around fiddling with something I know very little about but feeling pleased with myself, now just need to get rid of this headache! $\endgroup$– VinFeb 3, 2020 at 22:25
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
2
import bpy
from bpy.props import StringProperty, IntProperty, BoolProperty
from bpy.types import (
Operator,
GizmoGroup,
)
# CUTOM PANEL IN PROPERTIES OUTPUT PANEL
class CUSTOM_PT_menupanel(bpy.types.Panel):
"""Creates a Panel in the Output Properties of the properties editor"""
bl_label = "Test"
bl_idname = "SCENE_PT_layout"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "output"
def draw(self, context):
layout = self.layout
scene = context.scene
row = layout.row()
row.prop(scene, "gizmo_show_hide")
#SCREEN OVERLAY GIZMO
class Camera_overlay(GizmoGroup):
bl_idname = "Gizmo_Icon"
bl_label = "Gizmo"
bl_space_type = 'VIEW_3D'
bl_region_type = 'WINDOW'
bl_options = {'PERSISTENT', 'SCALE'}
@classmethod
def poll(cls, context):
scene = context.scene
if scene.gizmo_show_hide:
return False
else:
return True
def draw_prepare(self, context):
region = context.region
self.my_gizmo.matrix_basis[0][3] = region.width - 35
self.my_gizmo.matrix_basis[1][3] = 40
def setup(self, context):
mpr = self.gizmos.new("GIZMO_GT_button_2d")
mpr.icon = 'OUTLINER_OB_CAMERA'
mpr.draw_options = {'BACKDROP', 'OUTLINE'}
self.my_gizmo = mpr
#CHECKBOX GIZMO BOOL
bpy.types.Scene.gizmo_show_hide = BoolProperty(
name="Gizmo Hide",
description="Check Box to Show And Hide Gizmo",
default = True)
#CLASS LIST
classes = (
CUSTOM_PT_menupanel,
Camera_overlay,
)
#REGISTER AND UNREGISTER CLASSES
register, unregister = bpy.utils.register_classes_factory(classes)
if __name__ == "__main__":
register()
-
1$\begingroup$ As well as script an explanation of what you have done would be handy. Similarly for question. Would recommend naming the toggle say
gizmo_show
and simplyreturn scene.gizmo_show
in poll. $\endgroup$ Feb 4, 2020 at 6:02 -
$\begingroup$ Taken on board batFINGER and agreed that it's not only my python skills(lack of) that needs improving! I was a little over excited that this old one here managed to solve my own problem and forgot to list what i had added/changed/deleted. $\endgroup$– VinFeb 4, 2020 at 21:39