the class obprintbutton1(bpy.types.Operator):
does not work here
can someone point out how to correct this error
mport bpy
from bpy.props import *
from mathutils import *
from math import *
#
#bpy.context.scene.scn['MyInt'] = 17
# Store properties in the active scene
#
def initSceneProperties(scn):
bpy.types.Scene.MyInt = IntProperty(
name="Integer",
description="Enter an integer")
scn['MyInt'] = 17
bpy.types.Scene.MyFloat = FloatProperty(
name="Float",
description="Enter a float",
default = 33.33,
min = -100,
max = 100)
bpy.types.Scene.MyBool = BoolProperty(
name="Boolean",
description="True or False?")
scn['MyBool'] = True
bpy.types.Scene.MyEnum = EnumProperty(
items = [('Eine', 'Un', 'One'),
('Zwei', 'Deux', 'Two'),
('Drei', 'Trois', 'Three')],
name="Ziffer")
scn['MyEnum'] = 2
bpy.types.Scene.MyString = StringProperty(
name="String")
scn['MyString'] = "Lorem ipsum dolor sit amet"
return
initSceneProperties(bpy.context.scene)
# in UI n Transform panel
"""
bl_label = "Property panel"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_show_header=True
"""
#
# Menu in UI region n Transform panel
#
class UIPanel(bpy.types.Panel):
# in tool pro panel
bl_label = "Property panel" # Header Panel's name
bl_space_type = "VIEW_3D" # in 3D view
# bl_region_type = "TOOLS" # in tool shelf
bl_region_type = "TOOL_PROPS"
bl_show_header=True
def draw(self, context):
layout = self.layout
scn = context.scene
layout.prop(scn, 'MyInt', icon='BLENDER', toggle=True)
layout.prop(scn, 'MyFloat')
layout.prop(scn, 'MyBool')
layout.prop(scn, 'MyEnum')
layout.prop(scn, 'MyString')
layout.operator("object.PrintPropsButton")
print (' $$$$$$$$$$$ Doing Draw Function $$$$$$$$$$$ ')
#
# The button prints the values of the properites in the console.
#
class obprintbutton1(bpy.types.Operator):
bl_idname = "ob.printpropsbutton"
bl_label = "Print props"
def execute(self, context):
scn = context.scene
printProp("Int: ", 'MyInt', scn)
printProp("Float: ", 'MyFloat', scn)
printProp("Bool: ", 'MyBool', scn)
printProp("Enum: ", 'MyEnum', scn)
printProp("String: ", 'MyString', scn)
return{'FINISHED'}
def printProp(label, key, scn):
try:
val = scn[key]
except:
val = 'Undefined'
print("%s %s" % (key, val))
##########
bpy.utils.register_class(UIPanel)
bpy.utils.register_class(obprintbutton1)
also is there more then one way to register the class and how ?
thanks for any help