First python script help - randomizing faces


#1

Hi all,

I’m attempting to write a python script - but am having trouble figuring out a solution to a particular problem.

I’ve got this object which has thousands of battons;

I want to randomize the wood pattern so it all looks individual.

I have cobbled this together;

def getSpecificObjectsIntoArray(objectName):
	return cmds.ls(objectName)

def randomUV(objectName):
	for objects in getSpecificObjectsIntoArray(objectName):
		rN = rand.uniform(0,1)
        cmds.polyEditUV( relative=True, uValue=rN, vValue=rN )

randomUV('group*')

However it only works on selected UVs which means i have to currently select uv shells that i want to randomize.

How does one do a loop in python that cycles between uv shells in a selected object? Or faces for that matter.


#2

I suppose I could start the loop with this instead of objectName;

cmds.polyEvaluate( s=True )

:smiley:


#3

I guess you should work with UV shells. I will try to get code, when i will have time, or you can analyse existing script, like randomizer


#4

This is a script I wrote that does something close to what you are asking for. If nothing else it might be useful to see an example of one way to manipulate uv data in an efficient manner, on a per shell basis.

http://www.djx.com.au/blog/2012/07/28/djpfxuvs-for-maya-now-has-a-ui-and-does-grass/

David


#5

Thanks for the help guys, I will have a look through both of them and hack something together. :slight_smile: