mouseiop.blogg.se

Maya python setattr of list
Maya python setattr of list










maya python setattr of list

It then creates Clusters at those points and those clusters I’m still having trouble writing that.Ĭlass that takes two points and creates a linear curve between them. For the most part, the rig is complete, but it still is missing traits like an IK/FK align script.

MAYA PYTHON SETATTR OF LIST UPDATE

I’ve seen this kind of setup used a lot on pole vector controls so I thought I’d give it a shot.Īs an update on my leg rig, I’m currently working to give it more robust squash and stretch controls. Took a quick break from rigging and wrote this script that basically creates a line between two objects using a curve. # 3d distance formula is the square root of (x2-x1)**2 + (y2-y1)**2 + (z2-z1)**2ĭistance = math.sqrt( (pointB-pointA)**2Ĭmds.orientConstraint(start,end,sel,mo=1)Ĭmds.pointConstraint(start,end,sel,mo=1)Ĭmds.setAttr(sel + "_orientConstraint1." + start + "W0",W0)Ĭmds.setAttr(sel + "_orientConstraint1." + end + "W1",W1)Ĭmds.setAttr(sel + "_pointConstraint1." + start + "W0",W0)Ĭmds.setAttr(sel + "_pointConstraint1." + end + "W1",W1)Ĭmds.setAttr(sel + "_pointConstraint1.offsetX",0)Ĭmds.setAttr(sel + "_pointConstraint1.offsetY",0)Ĭmds.setAttr(sel + "_pointConstraint1.offsetZ",0) # This script akes the object's constraint weights to parent objects relative to its distance to them It could really come in handy for handling stuff like feathers that spread out in a way similar to this. This quick little script takes a group of objects and parents them to the start and end objects with parent weights based on the object’s distance to the two objects. SelAttr = cmds.channelBox("mainChannelBox", q=1, sma=1) # this command gets the currently selected attribute in the channel box # if nothing is selected in the channel box, do nothing

maya python setattr of list

# reverse the list below our moved attributeĭelAttr("%s.%s" % (sel, list)) # moves the attribute above it to the bottom of the list # this checks to see if the attribute we're trying to move down is already at the bottom we can't reorder default attrĪttrList = cmds.listAttr(sel, keyable=1, userDefined=1) # list the user keyable user defined attributes. # moves an attribute to the bottom of a list It works on one attribute at a time, so don’t expect to be able to move whole chunks of attributes at once. There’s a little more to it, but that’s essentially what the script does.

maya python setattr of list

Our list is now in the order that we wanted it and we moved A down one position. To get them back to their original order, we delete the attribute in front of the last attribute in the list (C) until it is after the attribute we wanted to move down (A). Notice something? After our attribute is moved to its proper position, the order of the attributes after it get reversed. We want A to be after B, so let’s delete the attributes in front of A until that’s so. With Maya’s delete/undo functionality, we’d get BCDEA. Let’s say I want to move “A” down one position in attribute list ABCDE so that we’d end with BACDE. Writing it out and doing it manually helped a lot for this problem. So with this trick in mind, I was curious to see if I could write a script that uses that single trick to fake the act of moving attributes up and down. When you delete an attribute and then undo, the attribute gets put at the bottom of the list and its connections are maintained. Ever get annoyed that you can’t re-arrange the attributes in the Channel Box? I certainly do, but there is something you can work with.












Maya python setattr of list