February 13th, 2014, 11:54 PM
Shuffling Colors Between Objects (Python)
I'm new to Python and was wondering how I can randomly shuffle the colors of 3 objects in a scene. Say I have: a cylinder, cone and sphere, and assign a lambert to each one, how's it possible to have their colors switch when scrolling through the timeline?
My instructor did something along the lines of this with 2 objects:
cmds.promptDialog(message='SELECT ONLY 2 Objects Dummy')
cmds.error('select only 2 objects')
and then used random.randint/shuffle
I tried to follow it but wasn't able to get it to work. Can someone pls help me? Thank you.
February 14th, 2014, 05:29 AM
cmds.promptDialog(message='SELECT EXACTLY 3 Objects Dummy')
cmds.error('select 3 objects')
(sg1, sg2, sg3,) = sgs = [cmds.listConnections(SHAPE,d=True,s=False,type='shadingEngine') for SHAPE in shape]
[cmds.sets(SHAPE,e=True,forceElement=SG) for (SHAPE, SG,) in zip(shape, sgs)]
# now employ random.shuffle in some way
[/code] are essential for python code and Makefiles!