This is a snipplet of my code thats for my exported the only problem I’ve found getMaterials() only prints 1 material thats linked to the object… And all I want to do is get all the materials used, but I have no idea how to get that really so I did it based on an object and so far seem thats not working either… Is there anyways to work around this?
import Blender
from Blender import NMesh, Object, Scene, Camera
blendscene = Scene.getCurrent()
sceneobjs = blendscene.getChildren()
objects = []
#----------------Get Objects-------------------
def cleanObjects():
global objects
for x in range(len(sceneobjs)):
fooStr = str(sceneobjs[x])
sLocation = int(fooStr.find('"'))
objectName = fooStr[sLocation+1:-2]
objects.append(objectName)
def getCamera():
global objects
x = objects.index("Camera")
cam.Name = "Camera"
location = str(Object.get(cam.Name).getLocation())
cam.Location = location[1:-1]
cam.LookAt = Object.get(cam.Name).getTracked()
cam.Ortho = Camera.get(cam.Name).type
cam.Lens = Camera.get(cam.Name).lens * 0.1
objects.remove("Camera")
#-----------------Print Material Data--------------
def printMaterials():
global objects
for x in range(len(objects)):
meshname = str(objects[x])
mesh = Object.get(meshname).getData
print mesh.getMaterials()
#-----------------Print Data--------------
cleanObjects()
getCamera()
printMaterials()