# creates attributes and connects them to setup a functional ik fk switchĭef CreateIKFKSwitch(resultObj, ikObj, fkObj):īaseObjects = GetAllRelativesAndSelf(resultObj) By doing all this, we sped up a tedious process. If you want to see a visual result, just open up the graph editor. Then it creates a blendcolor node which is pretty much a lerp.Then we connect the rotation attributes of the ik and fk chain to the base joints, making it so that the base joints are now fully in control of the two joint chains. Then it will create a group which holds an attribute for blending between ik or fk. This will create arrays of all the involved objects. Relatives = cmds.listRelatives(object, c=True, ad=True)Īnd that’s already the last part of the switch functionality.
#Maya python setattr shader color plus#
# returns an array of all relatives of a provided object plus itself The next paragraph contains a method which returns an object and its relatives, quite small and neat. NewName = name.replace(oldSubSring, newSubString) Relatives = GetAllRelativesAndSelf(newObj) NewObj = cmds.duplicate(oldObjectName,renameChildren=True) # duplicates the object with the name "oldObjectName" and replaces "oldSubSring" with "newSubString"ĭef CreateRenamedDuplicate(oldObjectName,oldSubSring, newSubString): Renaming is one of major time consuming import maya.cmds as cmds It searches for ‘oldSubString’ and replaces it with ‘newSubString’ while returning the duplicate object which is the highest one in the hierarchy. Furthermore all of it’s children and itself will be renamed based on the parameters.
#Maya python setattr shader color code#
The first code snippet contains a method for duplicating an object. This is a really short script and the usage at the bottom is specific to the naming conventions I use, but should be relatively easy to adjust. Creating an IK FK switch for several joint chains of a character is one of them. There are a lot of repetitive steps when rigging any type of object. MyRowShelfGroup=cmds.The following python script I wrote to speed up my rigging process. here is a working version import maya.cmds as cmds You need to move myBlinn,myBlinn2,myBlinn3=ShaderGen() in BookGen function to get what you looking for. You are using same shadernode over and over and finally all using same shadernode so you will get same color on all objects. MyRowShelfGroup=oup(em=True,n='RowShelfGroup') MyBlinn3 = cmds.shadingNode( 'blinn', asShader=True) MyBlinn2 = cmds.shadingNode( 'blinn', asShader=True) MyBlinn = cmds.shadingNode( 'blinn', asShader=True) Tmp=random.uniform(0.0,1.0) #Uniform function allow me to find a random FLOAT number between a range(not like randint!)Ĭmds.setAttr ( (myBlinn + '.color'), Colors,Colors,Colors, type = 'double3' ) MyBook=cmds.pol圜ube(name='Book',h=8,w=4,d=2) #Create a testCube with that Name I have this code.I don't understand why, whenever I do the for loop it doesn't change the color of the cube.I mean, in this case I call the function "BookGen" 5 times.And everytime i randomize 3 numbers, but the colors don't change.