Page 1 of 1

[Blendigo 3.4.9.4] Define external material with python

Posted: Thu Jan 23, 2014 2:39 am
by sowly
Hello everyone,

I have a question about some command in Python to define material to use in Indigo. I search in old topics but no one seems to use Python for Blendigo.

Here's my issue. I active an object and create a material for it, then I make that material a Indigo external material to use a .igm file with that command :

Code: Select all

bpy.types.indigo_material.type = 'external'
I thought it would just change the type of the active object but it turns out that all the other objects of the scene become external materials. I don't want that.

Did you guys know how to define a Indigo material and affect it to an object with python ?

I tried to do that :

Code: Select all

new_mat = bpy.types.indigo_material
new_mat.type = 'external'
But then my problem is that I can't find how to affect the material to my object.

Hope somebody can help me ! :)
Thanks already,
Sowly

Re: [Blendigo 3.4.9.4] Define external material with python

Posted: Sat Jan 25, 2014 1:56 am
by fused
Hi sowly,

materials automatically use the use the Indigo material properties when the Indigo renderer is set.

To create a material and set the type to external, try this:

Code: Select all

import bpy
import os

# Appends a material to an objects material list.
def applyMaterial(ob, mat):
    me = ob.data
    me.materials.append(mat)

# Make new material.
new_mat = bpy.data.materials.new('sowly\'s material')

# Apply material to currently selected object.
applyMaterial(bpy.context.object, new_mat)

# Set indigo material type to external.
new_mat.indigo_material.type = 'external'

# Set external materials filename.
new_mat.indigo_material.indigo_material_external.filename = 'C:/Users/Yves/Downloads/SturdyRock.igm'
Hope this helps :)

Re: [Blendigo 3.4.9.4] Define external material with python

Posted: Sat Jan 25, 2014 2:00 am
by sowly
Oh, I didn't think of that, I'll try this !

Thanks fused, I'll tell you if it works for me.