I’ve got a mesh, which I can export the geometry of, no worries. But how do I get access to it’s Material/Colour object?
thanks in advance
J.
I’ve got a mesh, which I can export the geometry of, no worries. But how do I get access to it’s Material/Colour object?
thanks in advance
J.
Depending on what you use, 2.23:
ob = Blender.Object.Get(objectname)
me = ob.data
matnames = me.mats
‘matnames’ is a list of material names. The list can be empty. The actual material you can get with:
for name in matnames:
# name can be None if material deleted
if name:
blendmat = Blender.Material.Get(name)
....
for Publisher:
ob = Blender.Object.get(objectname)
me = ob.getData()
materials = me.getMaterials()
‘materials’ is a list of the actual materials, not only the names, so no extra code needed.
Yeah, I do that and I only get an empty list (with publisher).
I’ve assigned two different colours to the same mesh, so it definitely has Materials. Any clues?
thanks
J.
Then I guess you didn’t assign the materials to the mesh but the object instead?
To get materials from the object:
ob= Blender.Object.get(objectname)
materials = ob.getMaterials()
You are not confusing materials with something else, like uv-textures maybe?
yeah, no, I’ve got it working now.
thanks… I’ve seen your handle splashed about a lot of these messages, Your knowledge and helpfulness is quite admirable. Greatly appreciated, I imagine not just by me.
J.