PDA

View Full Version : Materials and render partitions


rotaryman
02-01-2005, 12:30 AM
Hey all,
I am trying to write a function in JScript that checks to see if a material exists or not but I am not having any luck. What I am trying to do is this:

if(GetValue("Passes.MyPass.MyPartition.Material == null))
{
do something;
}else{
do something else;
}

now this function works perfectly fine if a material already exists and the rest of my script will work. However if no material exists on the partition, the script will error out:

//ERROR : 2000 - Argument 0 (Target) is invalid
//ERROR : 2001-GetValue - Argument 0 is invalid
//ERROR : Invalid procedure call or argument - [line 1]

Does anyone know of another way to inspect a partition if it has a material or not?

Thanks

Atyss
02-01-2005, 03:21 AM
Okay...... find the partition you wish to test, and then enumerate its local properties. Check if each property is a material, and perform action if so:

// Create enumerator and populate with local properties of partition
for( var oPartEnum = new Enumerator( selection(0).localproperties ); !oPartEnum.atEnd(); oPartEnum.moveNext() )
{
// Check if partition local property is a material
if( oPartEnum.item().type == siMaterialType )
{
logmessage( 'yo' );
}
}


Cheers
Bernard

rotaryman
02-01-2005, 05:47 AM
Rockstar! thanks a bunch, I got to learn more about enumerators, they seem damn handy!

Atyss
02-01-2005, 02:49 PM
I don't think the enumerator is documented. I have not seen it in the JScript manual from Microsoft nor the XSI documentation. You should google around if you want more info.

Btw, in JScript, get into the habit of using double-quotes, wich is the convention for JScript. I used single-quotes because I'm too used to Python now :)


Cheers
Bernard

rotaryman
02-01-2005, 03:40 PM
Yeah I have come to find out that a lot of stuff is either not documented or not document all that well. I remember complaining about this in my MEL days :-p, oh well.

CGTalk Moderation
02-01-2006, 04:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.