test_group_c.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # ############################################################
  2. # Importing - Same For All Render Layer Tests
  3. # ############################################################
  4. import unittest
  5. import os
  6. import sys
  7. from view_layer_common import *
  8. # ############################################################
  9. # Testing
  10. # ############################################################
  11. class UnitTesting(ViewLayerTesting):
  12. def test_group_create_basic(self):
  13. """
  14. More advanced creation of group from a collection not directly linked
  15. to the scene layer.
  16. """
  17. import bpy
  18. scene = bpy.context.scene
  19. # clean slate
  20. self.cleanup_tree()
  21. children = [bpy.data.objects.new("Child", None) for i in range(3)]
  22. master_collection = scene.master_collection
  23. grandma_scene_collection = master_collection.collections.new('Grand-Mother')
  24. mom_scene_collection = grandma_scene_collection.collections.new('Mother')
  25. grandma_scene_collection.objects.link(children[0])
  26. mom_scene_collection.objects.link(children[1])
  27. grandma_layer_collection = scene.view_layers[0].collections.link(grandma_scene_collection)
  28. mom_layer_collection = grandma_layer_collection.collections[mom_scene_collection.name]
  29. # update depsgraph
  30. bpy.context.view_layer.update()
  31. # create group
  32. group = mom_layer_collection.create_group()
  33. # update depsgraph
  34. bpy.context.view_layer.update()
  35. # ############################################################
  36. # Main - Same For All Render Layer Tests
  37. # ############################################################
  38. if __name__ == '__main__':
  39. UnitTesting._extra_arguments = setup_extra_arguments(__file__)
  40. unittest.main()