Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / Script using "polyColorPerVertex"?
  RSS 2.0 ATOM  

Script using "polyColorPerVertex"?
Rate this thread
 
53031
 
Permlink of this thread  
avatar
  • Location: Cookstown
  • Total Posts: 58
  • Joined: 17 May 2010 05:07 PM

I came up with the following Code to allow me to Select Objects in the scene and colour them in the same fashion as 3ds Max - but it is not working correctly.

//put selected objects into array
string $IF_Object[] = `ls - sl`;
//Loop through each object selected and colour it
for ($x=0$x<size($IF_Object); $x++)
{
 select $IF_Object[$x]
;
 
polyColorPerVertex -rgb `rand 0 1` `rand 0 1` `rand 0 1` -cdo ;
}

It only works if I manually select the objects with the mouse and then run the script.

I added the following line at the start of the script:

select -all;

When run on its’ own, the above line does select everything in the scene but when added into the script at the top it does not work at all!!!

I’m closer but not there yet!!!

Any help with this would be greatly appreciated.

Later…



______________________________
MIDIManNI (aka Ivan Flack)
Cookstown, N. Ireland

Replies: 0
avatar
  • THNKR
  • Posted: 07 March 2011 06:38 AM

//put selected objects into array
string $IF_Object[] = `ls -typ "mesh"`;
//Loop through each object selected and colour it
for ($x=0$x<size($IF_Object); $x++)
{
    polyColorPerVertex 
-rgb `rand 0 1` `rand 0 1` `rand 0 1` -cdo $IF_Object[$x];
}


Replies: 0
avatar

Thanks for clearing up my lack of knowledge.

This now does exactly what I needed.

Much obliged…



______________________________
MIDIManNI (aka Ivan Flack)
Cookstown, N. Ireland

Replies: 0