softocean
03-14-2008, 06:47 PM
Hi All,
I've been working on a script to recrusively list materials in a scene to check that all textures are present- before uploading a scene to the renderfarm.
However, I get stuck on scene files which have materials with layers in the color channel. Do you guys have any ideas on how I can recursively navigate into the layers in the Material manager using scripting?
thanks in advance --softocean
var doc = GetActiveDocument();
// Activates the bump channel for a material
var mat = doc->GetFirstMaterial();
//mat->SetChannelState(CHANNEL_BUMP, TRUE);
var max_count = 100;
var j;
for(j=0; (j < max_count) && (mat != NULL); j++) {
println("object:",j," name:",mat#ID_BASELIST_NAME);
// Sets a texture for it
var bump = mat->GetChannel(CHANNEL_BUMP);
if (bump != NULL) {
var bumpBc = bump->GetContainer();
// get data from Base Channel Class
var file = bumpBc->GetData(CH_TEXTURE);
if (file != NULL) {
println(" bump:",file);
}
}
var color1 = mat->GetChannel(CHANNEL_COLOR);
if (color1 != NULL) {
var colorC = color1->GetContainer();
var file = colorC->GetData(CH_TEXTURE);
if (file != NULL) {
println(" color:",file);
}
}
var alpha = mat->GetChannel(CHANNEL_ALPHA);
if (alpha != NULL) {
var alphaC = alpha->GetContainer();
var file = alphaC->GetData(CH_TEXTURE);
if (file != NULL) {
println(" alpha:",file);
}
}
mat = mat->GetNext();
}
I've been working on a script to recrusively list materials in a scene to check that all textures are present- before uploading a scene to the renderfarm.
However, I get stuck on scene files which have materials with layers in the color channel. Do you guys have any ideas on how I can recursively navigate into the layers in the Material manager using scripting?
thanks in advance --softocean
var doc = GetActiveDocument();
// Activates the bump channel for a material
var mat = doc->GetFirstMaterial();
//mat->SetChannelState(CHANNEL_BUMP, TRUE);
var max_count = 100;
var j;
for(j=0; (j < max_count) && (mat != NULL); j++) {
println("object:",j," name:",mat#ID_BASELIST_NAME);
// Sets a texture for it
var bump = mat->GetChannel(CHANNEL_BUMP);
if (bump != NULL) {
var bumpBc = bump->GetContainer();
// get data from Base Channel Class
var file = bumpBc->GetData(CH_TEXTURE);
if (file != NULL) {
println(" bump:",file);
}
}
var color1 = mat->GetChannel(CHANNEL_COLOR);
if (color1 != NULL) {
var colorC = color1->GetContainer();
var file = colorC->GetData(CH_TEXTURE);
if (file != NULL) {
println(" color:",file);
}
}
var alpha = mat->GetChannel(CHANNEL_ALPHA);
if (alpha != NULL) {
var alphaC = alpha->GetContainer();
var file = alphaC->GetData(CH_TEXTURE);
if (file != NULL) {
println(" alpha:",file);
}
}
mat = mat->GetNext();
}
