Advertisement
Guest User

Untitled

a guest
Dec 17th, 2014
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.25 KB | None | 0 0
  1. import bpy
  2. from bpy.props import EnumProperty
  3.  
  4. def updateEnumParameter(self,context):
  5.     print(self.my_axis)
  6.  
  7. class cls_IntFloatString(bpy.types.PropertyGroup):
  8.     axis_types = [
  9.                 ("0","None","None"),
  10.                 ("1","smile","smile"),
  11.                 ("2","content","content"),
  12.                 ("3","dizzy","dizzy"),
  13.                 ("4","cat","cat"),
  14.                 ("5","girl","girl"),
  15.                 ("6","yuck","yuck"),
  16.                 ("7","macho","macho"),
  17.                 ("8","pixel","pixel"),
  18.                 ("9","charming","charming"),
  19.                 ("10","cry","cry"),
  20.                 ("11","ouch","ouch"),
  21.                 ("12","ultraman","ultraman")
  22.                 ]
  23.     my_axis= EnumProperty(name="My Face", description="The axis that will be relayed to the target.", default="0", items=axis_types, update=updateEnumParameter)
  24.  
  25. bpy.utils.register_class(cls_IntFloatString)
  26.  
  27. # Add these properties to every object in the entire Blender system (muha-haa!!)
  28. bpy.types.Object.My_List_Index = bpy.props.IntProperty(min= 0,default= 0)
  29. bpy.types.Object.My_List = bpy.props.CollectionProperty(type=cls_IntFloatString)
  30.  
  31. class IntFloatStringPanel(bpy.types.Panel):
  32.     bl_label = "Int Float String"
  33.     bl_idname = "OBJECT_PT_hello"
  34.     bl_space_type = "PROPERTIES"
  35.     bl_region_type = "WINDOW"
  36.     bl_context = "object"
  37.  
  38.     def draw(self, context):
  39.         layout = self.layout
  40.        
  41.         ### context.object.My_List is never populated ###
  42.         obj = context.object
  43.         l = len(obj.My_List)
  44.  
  45.         if l > 0:
  46.             #layout.label(text="Hello World")
  47.             entry = obj.My_List[obj.My_List_Index]
  48.  
  49.             box1 = layout.box()
  50.             row1 = box1.row()
  51.             row1.label(" Label:", icon='INFO')
  52.          
  53.             # Display properties for each type.
  54.             box1.prop(entry, 'my_axis')
  55.         else:
  56.             layout.label(text="Hello World")
  57.             # This list is zero length, so let's add one.
  58.             collection = obj.My_List
  59.             collection.add()
  60.  
  61.  
  62. def register():
  63.     bpy.utils.register_class(IntFloatStringPanel)
  64.  
  65.  
  66. def unregister():
  67.     bpy.utils.unregister_class(IntFloatStringPanel)
  68.  
  69.  
  70. if __name__ == "__main__":
  71.     register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement