Advertisement
Guest User

Untitled

a guest
Aug 31st, 2020
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.49 KB | None | 0 0
  1. import bpy
  2.  
  3.  
  4.  
  5.  
  6.  
  7. class MyProperties(bpy.types.PropertyGroup):
  8.    
  9.     my_string : bpy.props.StringProperty(name= "Enter Text")
  10.    
  11.     my_float_vector : bpy.props.FloatVectorProperty(name= "Scale", soft_min= 0, soft_max= 1000, default= (1,1,1))
  12.    
  13.    
  14.  
  15.  
  16.  
  17.  
  18.  
  19. class ADDONNAME_PT_main_panel(bpy.types.Panel):
  20.     bl_label = "Main Panel"
  21.     bl_idname = "ADDONNAME_PT_main_panel"
  22.     bl_space_type = 'VIEW_3D'
  23.     bl_region_type = 'UI'
  24.     bl_category = "New Tab"
  25.  
  26.     def draw(self, context):
  27.         layout = self.layout
  28.         scene = context.scene
  29.         mytool = scene.my_tool
  30.        
  31.         layout.prop(mytool, "my_string")
  32.         layout.prop(mytool, "my_float_vector")
  33.        
  34.  
  35.         layout.operator("addonname.myop_operator")
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. class ADDONNAME_OT_my_op(bpy.types.Operator):
  43.     bl_label = "Add Object"
  44.     bl_idname = "addonname.myop_operator"
  45.    
  46.    
  47.    
  48.     def execute(self, context):
  49.         scene = context.scene
  50.         mytool = scene.my_tool
  51.        
  52.                
  53.         return {'FINISHED'}
  54.    
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64. classes = [MyProperties, ADDONNAME_PT_main_panel, ADDONNAME_OT_my_op]
  65.  
  66.  
  67.  
  68. def register():
  69.     for cls in classes:
  70.         bpy.utils.register_class(cls)
  71.        
  72.         bpy.types.Scene.my_tool = bpy.props.PointerProperty(type= MyProperties)
  73.  
  74. def unregister():
  75.     for cls in classes:
  76.         bpy.utils.unregister_class(cls)
  77.         del bpy.types.Scene.my_tool
  78.  
  79.  
  80.  
  81. if __name__ == "__main__":
  82.     register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement