Blender-Pipeline/studio/bpy_get_blend_content.py

63 lines
1.9 KiB
Python

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