__init__.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. # ----------------------------------------------------------
  2. # File __init__.py
  3. # ----------------------------------------------------------
  4. # Imports
  5. # Check if this add-on is being reloaded
  6. if "bpy" in locals():
  7. # reloading .py files
  8. import bpy
  9. import importlib
  10. # from . import zs_renderscene as zsrs
  11. # importlib.reload(zsrs)
  12. # or if this is the first load of this add-on
  13. else:
  14. import bpy
  15. import json
  16. from pathlib import Path
  17. # from . import zs_renderscene as zsrs # noqa
  18. # Addon info
  19. bl_info = {
  20. "name": "ZS Stable Diffusion Connection V0.0.1",
  21. "author": "Sergiu <sergiu@zixelise.com>",
  22. "Version": (0, 0, 1),
  23. "blender": (4, 00, 0),
  24. "category": "Scene",
  25. "description": "Stable Diffusion Connection",
  26. }
  27. # -------------------------------------------------------------------
  28. # Functions
  29. # -------------------------------------------------------------------
  30. def load_scene():
  31. print("Loading Scene")
  32. # load scene data
  33. # append products
  34. # append elements
  35. # append shapes
  36. # set lighting
  37. # set camera
  38. def append_objects():
  39. print("Appending Objects")
  40. # append objects
  41. # set transforms
  42. # -------------------------------------------------------------------
  43. # Operators
  44. # -------------------------------------------------------------------
  45. # load scene operator
  46. class ZSSD_OT_LoadScene(bpy.types.Operator):
  47. bl_idname = "zs_sd_loader.load_scene"
  48. bl_label = "Load Scene"
  49. bl_description = "Load Scene"
  50. def execute(self, context):
  51. load_scene()
  52. return {"FINISHED"}
  53. # parent class for panels
  54. class ZSSDPanel:
  55. bl_space_type = "VIEW_3D"
  56. bl_region_type = "UI"
  57. bl_category = "ZS SD Loader"
  58. # -------------------------------------------------------------------
  59. # Draw
  60. # -------------------------------------------------------------------
  61. # Panels
  62. class ZSSD_PT_Main(ZSSDPanel, bpy.types.Panel):
  63. bl_label = "SD Loader"
  64. def draw(self, context):
  65. layout = self.layout
  66. scene = context.scene
  67. col = layout.column()
  68. self.is_connected = False
  69. col.label(text="Stable Diffusion Connection")
  70. # load scene button
  71. col.operator("zs_sd_loader.load_scene", text="Load Scene")
  72. # modify after making products
  73. blender_classes = [
  74. ZSSD_PT_Main,
  75. ]
  76. def register():
  77. # register classes
  78. for blender_class in blender_classes:
  79. bpy.utils.register_class(blender_class)
  80. # Has to be afqter class registering to correctly register property
  81. # register global properties
  82. # register list
  83. # list data
  84. # bpy.types.Scene.zs_product_list = bpy.props.CollectionProperty(
  85. # type=ZS_Product_ListItem)
  86. # current item in list
  87. def unregister():
  88. # unregister classes
  89. for blender_class in blender_classes:
  90. bpy.utils.unregister_class(blender_class)
  91. # unregister global properties
  92. # unregister list items
  93. # del bpy.types.Scene.my_list
  94. # del bpy.types.Scene.product_product_list_index