sorry for the noob question, but i can't create a simple checkbox inside the render tab... Here is my code...
import bpy
from bpy import context
from math import degrees, floor
#from bpy.types import *
from bpy_extras.io_utils import ExportHelper
from bpy.props import BoolProperty
from bpy.types import (Panel,
Operator,
AddonPreferences,
PropertyGroup,
)
class MySettings(PropertyGroup):
my_bool = BoolProperty(
name = "render scene",
description = "render a reference copy of the scene",
default = False
)
class BlenderCam_exportFile(bpy.types.Operator):
bl_idname = "myops.blendercam_export_file"
bl_label = "Export File"
def execute(self, context):
#------------------------------------
# my code is here....
#------------------------------------
return {'FINISHED'}
class BlenderCamPanel(bpy.types.Panel):
"""Creates a Panel in the Render context of the properties editor"""
bl_label = "BlenderCam"
bl_idname = "blendercam_panel"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "render"
@classmethod
def poll(self,context):
return True
def draw(self, context):
layout = self.layout
scene = context.scene
rd = scene.render
#label
layout.label(text="Label")
#chechbox
layout.prop(rd, "my_bool", text="Bool Property")
#button
row = layout.row()
row.operator("myops.blendercam_export_file")
def register():
bpy.utils.register_class(BlenderCam_exportFile)
bpy.utils.register_class(BlenderCamPanel)
bpy.utils.register_class(MySettings)
def unregister():
bpy.utils.unregister_class(BlenderCam_exportFile)
bpy.utils.unregister_class(BlenderCamPanel)
bpy.utils.unregister_class(MySettings)
if __name__ == "__main__":
register()
The code runs fine and doesn't return any error, but while the label and the button are present, the checkbox doesn't show up... Any clue?
bpy.types.Scene.my_props = bpy.props.PointerProperty(type=MySettings)
as well as removing the pointer in the unregister sectiondel bpy.types.Scene.my_props
in you panel change tolayout.prop(scene.my_props, "my_bool", text="Bool Property")
and it should function but I'll let someone else answer for cleaner coding. $\endgroup$