Add Material with 2.25 API

(S68) #1

I was hacking around with an old script I was preparing and never finished because 2.23 API didn’t allow to easily add materials, hoping that new 2.25 API could help…

Script is (in a nutshell)

from Blender import *
from random import random

def sub1():

  for j in range(0,4):
    x = random()
    y = 0
    z = 0


  return me

sc = Scene.getCurrent()
ob = Object.New('Mesh','bof')

me = sub1()

mat = Material.New('bof')

Which looks fine as for API docs


I get my four vertices, and my material, but the material tab is RED, Material looks unassigned and rendering tends to crash everithing :frowning:

What’s wrong?

(Please note I don’t need faces, just vertexes, it is a halo stuff)

Thanx in advance


(eeshlo) #2

Again, another 2.25 bug, this worked in the last Blenderleague testversion, but not in the real 2.25.
The only solution seems to be linking the materials to the object instead of the mesh, replace the last three lines with this:

I also wouldn’t rely too much on the 2.25 docs, there are things in there that never made it to the release.

(S68) #3

I Know You Were The One With The Answer (TOWTA)

I’ll try…

yes, there’s a LOT of things in that doc which do not work at all…

Thanx :slight_smile: