Disable File (texture) Load (updated)

Hi there,

There is a way to disable file load in file nodes (Select a File node -> Turn on  Disable File Load).
That is helpful when you have heavy scenes with a lot of  high resolution texture.
However – as far as I know – Maya don’t have a built in feature to turn that on for the selected objects (more precisely to all related file nodes).

So here are a few simple MEL script to control/automate that:

Disable texture load to all

{
string $texSel[] = `ls -tex`;
for ($item in $texSel)
{
setAttr ($item + ".disableFileLoad") 1;
}
string $bumps[] = `ls -type "bump2d"`;
//print $bumps;
for ($item in $bumps)
{
string $bumpHistory[] = `listHistory $bumps`;
string $bumpFiles[] = `ls -type "file" $bumpHistory`;
for ($item in $bumpFiles)
{
setAttr ($item + ".defaultColor") 0.214 0.214 1;
//print $bumpFiles;
}
}
}

Enable texture load to all

{
string $texSel[] = `ls -tex`;
for ($item in $texSel)
{
setAttr ($item + ".disableFileLoad") 0;
}
}

Disable texture load for selected objects

string $sel[] = `ls -l -sl -tr`;
string $shader[] = `listHistory -f 1 $sel`;
string $history[] = `listHistory $shader`;
string $files[] = `ls -type "file" $history`;
string $bumps[] = `ls -type "bump2d" $history`;
//print $files;
for ($item in $files)
{
setAttr ($item + ".disableFileLoad") 1;
}
for ($item in $bumps)
{
string $bumpHistory[] = `listHistory $bumps`;
string $bumpFiles[] = `ls -type "file" $bumpHistory`;
for ($item in $bumpFiles)
{
setAttr ($item + ".defaultColor") -type double3 0.5 0.5 1;
//print $bumpFiles;
}
}

Enable texture load for selected objects

string $sel[] = `ls -l -sl -tr`;
string $shader[] = `listHistory -f 1 $sel`;
string $history[] = `listHistory $shader`;
string $files[] = `ls -type "file" $history`;
string $bumps[] = `ls -type "bump2d" $history`;
//print $files;
for ($item in $files)
{
setAttr ($item + ".disableFileLoad") 0;
}

This works only if all the nodes are generated using the construction history.
It’s turned on by default for every type of nodes – so don’t worry :).

I found that, this has no effect on the Arnold rendering process.

Cheers, D

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.