class Limbs(object):
def __init__(self):
self.ikHandles=[]
self.IKrigJnts=[]
self.FKrigJnts=[]
self.pvPos=[]
# dictionaries
self.dHandles={}
self.dIkjnts={}
self.dFkjnts={}
self.dPvPos={}
def prepLimb(self,limbName,rigJoints,IK,FK,mirror):
if mirror:
#split the rigJoints list into separate sublists
for i,mirroredJnts in enumerate(rigJoints):
self.buildLimb(limbName,mirroredJnts, IK, FK)
else:
self.buildLimb(limbName,rigJoints, IK, FK)
def buildLimb(self,limbName,rigJoints,IK,FK):
# create the limbs
self.dIkjnts={"leg":[[IK_L_upLeg_JNT,IK_L_knee_JNT,IK_L_ankle_JNT],[IK_R_upLeg_JNT,IK_R_knee_JNT,IK_R_ankle_JNT]],"arm":[[IK_L_shoulder_JNT,IK_L_elbow_JNT,IK_L_wrist_JNT],[IK_R_shoulder_JNT,IK_R_elbow_JNT,IK_R_wrist_JNT]]}# arm setup
limb="arm"
armIkjnts=self.dIkjnts[limb]
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/ad86e5eb-5875-4d9c-b03b-2ece26f59fa7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#self.ikHandles.append(allHandles)
# update ikHandle dictionary
self.dHandles[limbName]=self.ikHandles
self.IKrigJnts.append(IKjoints)
# update IK dictionary
self.dIkjnts[limbName]=self.IKrigJnts self.dHandles[limbName]=allHandles
self.dIkjnts[limbName]=IKjointsI didn't extensively examine your pastebin, but one thing that stands out is that you seem to be appending sets of lists to your ikHandles list, and then assigning that list as the value to every limbName in your dHandles dict:self.ikHandles.append(allHandles)self.dHandles[limbName]=self.ikHandlesAnd you do the same for the other lists and dicts. So each limbName ends up referencing the entirely same list, if I am reading it correctly.Any reason to keep discreet lists and dicts instead of just dicts, where you manage the list of each dict key?self.ikHandles = {}...self.ikHandles[limbName] = handles
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/fce358ea-06a9-4467-b00a-7dc119a33cfe%40googlegroups.com.
On 15/10/2014 2:45 AM, "flaye" <eyal...@gmail.com> wrote:
>
> Hi Justin,
>
> Thanks for that tip. So I'm guessing then I don't need to append the objects to the list?
>
> From this:
> #self.ikHandles.append(allHandles)
>
> # update ikHandle dictionary
> self.dHandles[limbName]=self.ikHandles
>
>
> self.IKrigJnts.append(IKjoints)
>
> # update IK dictionary
> self.dIkjnts[limbName]=self.IKrigJnts
>
>
> to this?
> self.dHandles[limbName]=allHandles
>
>
Pretty much, yea. Instead of trying to maintain both a list and a dictionary that just associates a name with the list... just maintain the dictionary
>
> self.dIkjnts[limbName]=IKjoints
>
>
> Thanks,
>
>
>
> On Tuesday, October 14, 2014 5:16:30 AM UTC-4, Justin Israel wrote:
>>
>> I didn't extensively examine your pastebin, but one thing that stands out is that you seem to be appending sets of lists to your ikHandles list, and then assigning that list as the value to every limbName in your dHandles dict:
>>
>> self.ikHandles.append(allHandles)
>> self.dHandles[limbName]=self.ikHandles
>>
>> And you do the same for the other lists and dicts. So each limbName ends up referencing the entirely same list, if I am reading it correctly.
>> Any reason to keep discreet lists and dicts instead of just dicts, where you manage the list of each dict key?
>>
>> self.ikHandles = {}
>> ...
>> self.ikHandles[limbName] = handles
>>
>>
>>
>>
>>
> --
> You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/fce358ea-06a9-4467-b00a-7dc119a33cfe%40googlegroups.com.
self.dHandles[limbName]=allHandlesself.dHandles[limbName].append(allHandles)
self.dHandles.setdefault(limbName,[]).append(allHandles)
Solved it:
Tried initiallyself.dHandles[limbName]=allHandles
but the dictionary kept returning only one value list.
Tried alsoself.dHandles[limbName].append(allHandles)
with the same result.
Finally, got this to work like a charm:
self.dHandles.setdefault(limbName,[]).append(allHandles)
Had to do some digging, but happy with the result, and a lot cleaner than my original code. Justin, thanks again for pointing out the redundancy.
@Eduardo: Thanks for the red9 links. Great stuff indeed. I'm on purpose trying to get my own code in place. I'm writing an introductory primer on rigging for those who want to learn how to be a TD. Part of the trial and error process.
As for the message nodes, definitely something to explore, but that's a more advanced stage.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/810e971a-2385-4a31-b32d-801cdee83d35%40googlegroups.com.