PDA

View Full Version : script for changing viewport texture resolution... ?


Eightball
04-30-2009, 02:37 PM
Hi peeps!

I posted my problem in the texturing forum and they told me to ask you guys. ;)

The original issue was, that I wanted to find a neat option inside of maya to change the texture resolution of file textures within the maya viewport.
We found out, that you can simply add an integer attribute to the file node called "resolution" which will let you change the viewport resolution "on the fly".

Perfect so far!

Now I've got a pretty heavy scene and a lot of textures, which I would like to do this with.
What would be the script to add that new attribute to all the selected file nodes at once? And how could I change that for all of them together?

I know it had something to do with generating a list of all the selected objects and putting this into a variable, but I really can't get it together... :(

Is it also possible to automatically do that, while not even having the file node selected, but the object which it is applied to?
Lets say, I have a cube, with a lambert assigned to it which gets its color and bump info from two file nodes. Is it possible to change those two file node's "resolution" value, while only having selected the cube?

Hope you can help me there. I've never done anything in MEL, that exceeded 2 lines. ;)

Thanks a lot!
Alex

gashworm
05-01-2009, 03:35 AM
This should take care off all file nodes in the scene. Should be a good start .

eg
BumpMaxTextureResolution(256);
to base it on the selected nodes change

ls -type "file" to ls -sl -type "file"


global proc BumpMaxTextureResolution(int $maxRes)
{


string $files[] = `ls -type "file"`;


for ($file in $files)
{

if (!`attributeExists "resolution" $file`) addAttr -ln "resolution" -at long $file;

setAttr ($file + ".resolution") $maxRes;
}

}

Eightball
05-04-2009, 04:13 PM
I just installed this script, and it's just GREAT!

It works perfectly!

I'd only really like to know if there was a way to automatically manipulate the attributes on the file node, while having the object selected it is assigned to.

Thanks so much! This is such a timesaver!

Alex

CGTalk Moderation
05-04-2009, 04:13 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.