bpy_get_blend_content.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # THIS FILE IS A PART OF VCStudio
  2. # PYTHON 3
  3. # BPY ( WITH IN BLENDER )
  4. #################################################################
  5. # This file is running with in Blender to link get data from blend
  6. # files about their contents.
  7. # NOTE: It's using BPY module which is not available outside of
  8. # blender. So in order to test any changes to it. You have to
  9. # run it with in Blender. Or Using blender -P <your_script>.
  10. # See blender --help for details.
  11. #################################################################
  12. import bpy
  13. # Basically I want to have 3 types of data.
  14. # 0. What collections does the blend file has.
  15. # 1. What objects does the blend file has. And in what collection are they.
  16. # 2. Whether those objects are armatures. Or in other words what types are
  17. # these objects.
  18. # It's not going to work on pre 2.80 blenders. So there is this try.
  19. try:
  20. # Now let's look through all the collections that the blend file has.
  21. for n, i in enumerate(bpy.data.collections):
  22. # Then I want to know whether in this collection are any objects.
  23. foundobj = False
  24. # So let's try itterating through the object os the collection.
  25. for nn, b in enumerate(i.objects):
  26. # If we found enything there is this.
  27. foundobj = True
  28. print( ">>>", i.name, "<==" ,b.name, "<==" ,b.data)
  29. # Now some scenes have terribly huge amount of
  30. # stuff in there. This is why I break early.
  31. # Now this value probably should be done using a
  32. # setting in the UI somewhere. I'm not sure how
  33. # to do it yet. So yeah.
  34. if nn > 200:
  35. print("BROKEN AFTER", b.name)
  36. break
  37. if not foundobj:
  38. print( ">>>", i.name)
  39. #if n > 300:
  40. # break
  41. print ("VERSION = SUCCESS")
  42. except:
  43. print("ERROR")