Advertisement
Guest User

Untitled

a guest
Sep 8th, 2019
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.25 KB | None | 0 0
  1. bl_info = {
  2.     "name": "Add-on Template",
  3.     "description": "",
  4.     "author": "p2or",
  5.     "version": (0, 0, 3),
  6.     "blender": (2, 80, 0),
  7.     "location": "3D View > Tools",
  8.     "warning": "", # used for warning icon and text in addons panel
  9.     "wiki_url": "",
  10.     "tracker_url": "",
  11.     "category": "Development"
  12. }
  13.  
  14.  
  15. import bpy
  16.  
  17. from bpy.props import (StringProperty,
  18.                        BoolProperty,
  19.                        IntProperty,
  20.                        FloatProperty,
  21.                        FloatVectorProperty,
  22.                        EnumProperty,
  23.                        PointerProperty,
  24.                        )
  25. from bpy.types import (Panel,
  26.                        Menu,
  27.                        Operator,
  28.                        PropertyGroup,
  29.                        )
  30.  
  31.  
  32. # ------------------------------------------------------------------------
  33. #    Scene Properties
  34. # ------------------------------------------------------------------------
  35.  
  36. def my_callback(scene, context):
  37.  
  38.     items = [
  39.         ('GA', "Asset", "tooltip"),
  40.         ('LP', "Low", "tooltip"),
  41.         ('HP', "High", "High Poly"),
  42.     ]
  43.  
  44.     return items
  45.  
  46.  
  47. class MyProperties(PropertyGroup):
  48.  
  49.     my_bool: BoolProperty(
  50.         name="Enable or Disable",
  51.         description="A bool property",
  52.         default = False
  53.         )
  54.    
  55.     # define asset mode types
  56.     fbx_mode: EnumProperty(
  57.         name="Dropdown:",
  58.         description="Apply Data to attribute.",
  59.         items=my_callback
  60.         )
  61.    
  62.     # collection spawner
  63.     fbx_spawner: EnumProperty(
  64.         name="File Spawners",
  65.         options={'ENUM_FLAG'},
  66.         items=my_callback,
  67.         description="tooltip",
  68.         )
  69.  
  70. # ------------------------------------------------------------------------
  71. #    Panel in Object Mode
  72. # ------------------------------------------------------------------------
  73.  
  74. class OBJECT_PT_CustomPanel(Panel):
  75.     bl_label = "My Panel"
  76.     bl_idname = "OBJECT_PT_custom_panel"
  77.     bl_space_type = "VIEW_3D"  
  78.     bl_region_type = "UI"
  79.     bl_category = "Tools"
  80.     bl_context = "objectmode"  
  81.  
  82.  
  83.     @classmethod
  84.     def poll(self,context):
  85.         return context.object is not None
  86.  
  87.     def draw(self, context):
  88.         layout = self.layout
  89.         scene = context.scene
  90.         mytool = scene.my_tool
  91.  
  92.         layout.prop(mytool, "my_bool")
  93.         layout.prop(mytool, "fbx_mode", text="")
  94.        
  95.         layout.label(text="Spawner:")
  96.        
  97.         layout.prop(mytool, "fbx_spawner") #?
  98.         # Alternatively expand the property:
  99.         layout.prop(mytool, "fbx_mode", expand=True)
  100.  
  101.         layout.separator()
  102.  
  103. # ------------------------------------------------------------------------
  104. #    Registration
  105. # ------------------------------------------------------------------------
  106.  
  107. classes = (
  108.     MyProperties,
  109.     OBJECT_PT_CustomPanel
  110. )
  111.  
  112. def register():
  113.     from bpy.utils import register_class
  114.     for cls in classes:
  115.         register_class(cls)
  116.  
  117.     bpy.types.Scene.my_tool = PointerProperty(type=MyProperties)
  118.  
  119. def unregister():
  120.     from bpy.utils import unregister_class
  121.     for cls in reversed(classes):
  122.         unregister_class(cls)
  123.     del bpy.types.Scene.my_tool
  124.  
  125.  
  126. if __name__ == "__main__":
  127.     register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement