
scnType = bpy.types.Scene # saves typing StringProperty = bpy.props.StringProperty FloatProperty = bpy.props.FloatProperty IntProperty = bpy.props.IntProperty BoolProperty = bpy.props.BoolProperty # single value properties. scnType.my_string_prop = StringProperty( name="Example String", default="hello", description = "An example string property") scnType.my_float_prop = FloatProperty( name = "Example Float", default = .5, min = 0, max=1, description = "An example float property" ) scnType.my_int_prop = IntProperty( name = "Example Int", default = 5, min = 0, max = 10, description = "An example integer" ) scnType.my_bool_prop = BoolProperty( name="Example Bool", description = "This is a boolean", default=True )

Single Value Property Widgets
# vector based properties( commonly used to refer to some 3D sense of a thing )
BoolVectorProperty = bpy.props.BoolVectorProperty
IntVectorProperty = bpy.props.IntVectorProperty
FloatVectorProperty = bpy.props.FloatVectorProperty
scnType.my_bool_vector = BoolVectorProperty( name = "Example Bool Vector",
description = "Bool Vector Description",
default = ( True, False, True) )
scnType.my_int_vector = IntVectorProperty( name = "Example Int Vector",
description = "Int Vector Description",
default = ( 2,5,7), min = 0, max=10)
scnType.my_float_vector = FloatVectorProperty( name = "Example float vector",
description = "Float Vector Description",
default = ( 3.2, 5.6, 1.0 ),
min = 0, max = 7 )
Vector Value Property Widgets
# triplet setup.... ( return value, name, description ) animaniacs = [ ( "Yaco1", "Yaco", "Yaco Warner Desc" ), ( "Wacko2", "Wacko", "Wacko Warner Desc" ), ( "Dot3", "Dot", "Dot Warner Desc" )] enumProp = bpy.props.EnumProperty( name = "Cartoon Characters", items = animaniacs, description = "Choose a character" ) scnType.dropDownProp = enumProp
List Value Property Widget
"""
Type Samples - A Collection of types set up to be displayed in the
object properties panel
Hit alt-p to run this.
Go to object properties and scroll to the bottom to view.
"""
import bpy
class TypeSamplerPanel(bpy.types.Panel):
bl_label = "Type Samples"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
def draw(self, context):
scn = bpy.context.scene
layout = self.layout
row = layout.row()
col = row.column()
col.prop( scn, "my_string_prop" )
col.prop( scn, "my_float_prop" )
col.prop( scn, "my_int_prop" )
col.prop( scn, "my_bool_prop" )
col.prop( scn, "my_bool_vector" )
col.prop( scn, "my_int_vector" )
col.prop( scn, "my_float_vector" )
col.prop( scn, "dropDownProp" )
col.operator( "bpt.sample_op" )
class SampleOperator(bpy.types.Operator):
bl_idname = "bpt.sample_op"
bl_label = "Sample Button Caption"
def invoke(self, context, event ):
self.report( "INFO", "I PUSHED THE BUTTON" )
return {'FINISHED'}
def register():
bpy.utils.register_class( TypeSamplerPanel )
bpy.utils.register_class( SampleOperator )
def unregister():
bpy.utils.register_class( TypeSamplerPanel )
bpy.utils.register_class( SampleOperator )
if __name__ == "__main__":
register()
if __name__ == '__main__':
scnType = bpy.types.Scene
# single value properties.
StringProperty = bpy.props.StringProperty
FloatProperty = bpy.props.FloatProperty
IntProperty = bpy.props.IntProperty
BoolProperty = bpy.props.BoolProperty
scnType.my_string_prop = StringProperty( name="Example String",
default="hello",
description = "String Property Desc")
scnType.my_float_prop = FloatProperty( name = "Example Float",
default = .5, min = 0, max=1,
description = "Float Prop Desc" )
scnType.my_int_prop = IntProperty( name = "Example Int",
default = 5, min = 0, max = 10,
description = "Int Prop Desc" )
scnType.my_bool_prop = BoolProperty( name="Example Bool",
description = "Bool Prop Desc",
default=True )
# vector based properties
# ( commonly used to refer to some 3D sense of a thing )
BoolVectorProperty = bpy.props.BoolVectorProperty
IntVectorProperty = bpy.props.IntVectorProperty
FloatVectorProperty = bpy.props.FloatVectorProperty
scnType.my_bool_vector = BoolVectorProperty( name = "Example Bool Vector",
description = "Bool Vector Desc",
default = ( True, False, True) )
scnType.my_int_vector = IntVectorProperty( name = "Example Int Vector",
description = "Int Vector Desc",
default = ( 2,5,7),
min = 0, max=10)
scnType.my_float_vector = FloatVectorProperty( name = "Example float vector",
description = "Float Vector Desc",
default = ( 3.2, 5.6, 1.0 ),
min = 0, max = 7 )
# triplet setup.... ( return value, name, description )
EnumProperty = bpy.props.EnumProperty
animaniacs = [ ( "Yaco1", "Yaco", "Yaco Warner Desc" ),
( "Wacko2", "Wacko", "Wacko Warner Desc" ),
( "Dot3", "Dot", "Dot Warner Desc" )]
enumProp = EnumProperty( name = "Cartoon Characters", items = animaniacs,
description = "Choose a character" )
scnType.dropDownProp = enumProp