def returnSegmentedJointList(limbJoints): cullList = copy.copy(limbJoints) """put objects in order of closeness to root""" cullList = distance.returnDistanceSortedList(cullList[0], cullList) #>>> Segment our joint list by names jointSegmentsList = [] while len(cullList) > 0: matchTerm = search.returnTagInfo(cullList[0], 'cgmName') objSet = returnMatchedTagsFromObjectList(cullList, 'cgmName', matchTerm) jointSegmentsList.append(objSet) for obj in objSet: cullList.remove(obj) return jointSegmentsList
def returnSegmentedJointList(limbJoints): cullList = copy.copy(limbJoints) """put objects in order of closeness to root""" cullList = distance.returnDistanceSortedList(cullList[0],cullList) #>>> Segment our joint list by names jointSegmentsList = [] while len(cullList) > 0: matchTerm = search.returnTagInfo(cullList[0],'cgmName') objSet = returnMatchedTagsFromObjectList(cullList,'cgmName',matchTerm) jointSegmentsList.append(objSet) for obj in objSet: cullList.remove(obj) return jointSegmentsList
def saveTemplateToModule(moduleNull): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: * Save the new positional information from the template objects * Collect all names of objects for a delete list * If anything in the module doesn't belong there, un parent it, report it * like a template object parented to another obect ARGUMENTS: moduleNull(string) RETURNS: limbJoints(list) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Variables #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Get our base info """ module null data """ moduleNullData = attributes.returnUserAttrsToDict(moduleNull) """ part name """ partName = NameFactory.returnUniqueGeneratedName(moduleNull, ignore='cgmType') partType = moduleNullData.get('cgmModuleType') direction = moduleNullData.get('cgmDirection') """ template null """ templateNull = moduleNullData.get('templateNull') templateNullData = attributes.returnUserAttrsToDict(templateNull) """ template object nulls """ templatePosObjectsInfoNull = returnInfoTypeNull(moduleNull, 'templatePosObjects') templatePosObjectsInfoData = attributes.returnUserAttrsToDict( templatePosObjectsInfoNull) templateControlObjectsNull = returnInfoTypeNull(moduleNull, 'templateControlObjects') templateControlObjectsData = attributes.returnUserAttrsToDict( templateControlObjectsNull) """ rig null """ rigNull = moduleNullData.get('rigNull') """ Start objects stuff """ templateStarterDataInfoNull = returnInfoTypeNull(moduleNull, 'templateStarterData') templateControlObjectsDataNull = returnInfoTypeNull( moduleNull, 'templateControlObjectsData') """ AutonameStuff """ divider = NameFactory.returnCGMDivider() moduleRootBuffer = returnInfoNullObjects(moduleNull, 'templatePosObjects', types='templateRoot') moduleRoot = moduleRootBuffer[0] templateObjects = [] coreNamesArray = [] #>>>TemplateInfo for key in templatePosObjectsInfoData.keys(): if (mc.attributeQuery(key, node=templatePosObjectsInfoNull, msg=True)) == True: templateObjects.append(templatePosObjectsInfoData[key]) coreNamesArray.append(key) posTemplateObjects = [] """ Get the positional template objects""" for obj in templateObjects: bufferList = obj.split(divider) if (typesDictionary.get('templateObject')) in bufferList: posTemplateObjects.append(obj) """ get our control template objects """ controlTemplateObjects = [] for key in templateControlObjectsData.keys(): if (mc.attributeQuery(key, node=templateControlObjectsNull, msg=True)) == True: controlTemplateObjects.append(templateControlObjectsData[key]) """put objects in order of closeness to root""" posTemplateObjects = distance.returnDistanceSortedList( moduleRoot, posTemplateObjects) controlTemplateObjects = distance.returnDistanceSortedList( moduleRoot, controlTemplateObjects) curve = (templatePosObjectsInfoData['curve']) #>>> get our orientation helpers helperObjects = [] for obj in posTemplateObjects: helperObjects.append( attributes.returnMessageObject(obj, 'orientHelper')) masterOrient = (attributes.returnMessageObject(moduleRoot, 'orientHelper')) print('%s%s' % (moduleNull, ' data acquired...')) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Save Data #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Get the data """ pos objects """ storageData = [] for obj in posTemplateObjects: storageData.append(mc.xform(obj, q=True, ws=True, sp=True)) """ orientation helpers """ for obj in helperObjects: storageData.append(mc.xform(obj, q=True, os=True, ro=True)) storageData.append(mc.xform(masterOrient, q=True, os=True, ro=True)) print storageData """ template control objects data""" tempateControlObjectsStorageData = [] for obj in controlTemplateObjects: print obj tempateControlObjectsStorageData.append( mc.xform(obj, q=True, ws=True, t=True)) tempateControlObjectsStorageData.append( mc.xform(obj, q=True, os=True, ro=True)) rootScale = (mc.xform(moduleRoot, q=True, relative=True, scale=True)) objScaleBuffer = (mc.xform(obj, q=True, relative=True, scale=True)) objScale = [] cnt = 0 for scale in objScaleBuffer: objScale.append(scale * rootScale[cnt]) cnt += 1 tempateControlObjectsStorageData.append(objScale) print tempateControlObjectsStorageData #>>> Store the data to the initial objects pos """ Get the attributes to store to""" initialObjectsTemplateDataBuffer = attributes.returnUserAttrsToList( templateStarterDataInfoNull) initialObjectsPosData = lists.removeMatchedIndexEntries( initialObjectsTemplateDataBuffer, 'cgm') """ store it""" cnt = 0 for set in initialObjectsPosData: attrBuffer = set[0] xBuffer = (templateStarterDataInfoNull + '.' + attrBuffer + 'X') yBuffer = (templateStarterDataInfoNull + '.' + attrBuffer + 'Y') zBuffer = (templateStarterDataInfoNull + '.' + attrBuffer + 'Z') dataSet = storageData[cnt] mc.setAttr(xBuffer, dataSet[0]) mc.setAttr(yBuffer, dataSet[1]) mc.setAttr(zBuffer, dataSet[2]) cnt += 1 #>>> Store the data to the initial objects pos """ Get the attributes to store to""" templateControlObjectsDataNullBuffer = attributes.returnUserAttrsToList( templateControlObjectsDataNull) templateControlObjectsData = lists.removeMatchedIndexEntries( templateControlObjectsDataNullBuffer, 'cgm') """ store it""" cnt = 0 for set in templateControlObjectsData: attrBuffer = set[0] xBuffer = (templateControlObjectsDataNull + '.' + attrBuffer + 'X') yBuffer = (templateControlObjectsDataNull + '.' + attrBuffer + 'Y') zBuffer = (templateControlObjectsDataNull + '.' + attrBuffer + 'Z') dataSet = tempateControlObjectsStorageData[cnt] mc.setAttr(xBuffer, dataSet[0]) mc.setAttr(yBuffer, dataSet[1]) mc.setAttr(zBuffer, dataSet[2]) cnt += 1 #>>>>>>need to add locking>>>>>>>>>>>>>>>>>>>>>>>>>>>> print('%s%s' % (moduleNull, ' template object positional/rotational/scale data stored...')) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Save skin joints to skin joints null #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Delete stuff #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ Gather our objects""" toDeleteList = search.returnObjectsOwnedByModuleNull(templateNull) print toDeleteList for obj in toDeleteList: if mc.objExists(obj) == True: print('%s%s' % (obj, ' deleted...')) mc.delete(obj) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Change Tag #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> mc.setAttr((moduleNull + '.templateState'), 0) mc.setAttr((moduleNull + '.skeletonState'), 1) #add locking print('%s%s' % (moduleNull, ' done')) return 'done'
def rigSpine(moduleNull): #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>>Get our info #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> partName = NameFactory.returnUniqueGeneratedName(moduleNull, ignore='cgmType') """ template null """ templateNull = modules.returnTemplateNull(moduleNull) templateNullData = attributes.returnUserAttrsToDict(templateNull) jointOrientation = modules.returnSettingsData('jointOrientation') templateRoot = modules.returnInfoNullObjects(moduleNull, 'templatePosObjects', types='templateRoot') """ AutonameStuff """ divider = NameFactory.returnCGMDivider() """ control helper objects """ controlTemplateObjects = modules.returnInfoNullObjects( moduleNull, 'templateControlObjects', types='all') controlTemplateObjects = distance.returnDistanceSortedList( templateRoot, controlTemplateObjects) print 'controlTemplateObjects...' print controlTemplateObjects """size list of template control objects """ controlTemplateObjectsSizes = [] for obj in controlTemplateObjects: controlTemplateObjectsSizes.append( distance.returnAbsoluteSizeCurve(obj)) print 'sizes...' print controlTemplateObjectsSizes """ Skin Joints """ skinJoints = modules.returnInfoNullObjects(moduleNull, 'skinJoints', types='all') skinJoints = distance.returnDistanceSortedList(templateRoot, skinJoints) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Make Controls #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ control options """ fk = templateNullData.get('fk') ik = templateNullData.get('ik') stretch = templateNullData.get('stretch') bend = templateNullData.get('bend') """controls to make """ controlsToMake = [] controlsToMake.append('cog') if fk == True: controlsToMake.append('segmentControls') controlsToMake.append('hips') if ik == True: controlsToMake.append('vectorHandles') controlsToMake.append('spineIKHandle') controlsDict = modules.limbControlMaker(moduleNull, controlsToMake) print controlsDict #>>> Organize em segmentControls = controlsDict.get('segmentControls') spineIKHandle = controlsDict.get('spineIKHandle') cog = controlsDict.get('cog') hips = controlsDict.get('hips') vectorHandles = controlsDict.get('vectorHandles') for handle in vectorHandles[-1:]: mc.delete(handle) vectorHandles.remove(handle) #>>> Parent em rigging.parentListToHeirarchy(segmentControls) mc.parent(spineIKHandle, segmentControls[-1]) mc.parent(segmentControls[0], cog) mc.parent(hips, cog) for obj in segmentControls: rigging.zeroTransformMeObject(obj) mc.makeIdentity(obj, apply=True, translate=True) for obj in vectorHandles: mc.makeIdentity(obj, apply=True, translate=True) """ hips anchor locator """ locBuffer = locators.locMeObject(hips) attributes.storeInfo(locBuffer, 'cgmName', hips) attributes.storeInfo(locBuffer, 'cgmTypeModifier', 'anchor') hipsAnchor = NameFactory.doNameObject(locBuffer) mc.setAttr((hipsAnchor + '.rotateOrder'), 5) pointConstraintBuffer = mc.pointConstraint(hips, hipsAnchor, maintainOffset=False, weight=1) orientConstraintBuffer = mc.orientConstraint(hips, hipsAnchor, maintainOffset=False, skip=['x', 'y'], weight=1) """ hips anchor group constraint """ groupBuffer = rigging.groupMeObject(hipsAnchor) attributes.storeInfo(groupBuffer, 'cgmName', hipsAnchor) attributes.storeInfo(groupBuffer, 'cgmTypeModifier', 'orient') hipsAnchorOrGroup = NameFactory.doNameObject(groupBuffer) orientConstraintBuffer = mc.orientConstraint(segmentControls[0], hipsAnchorOrGroup, maintainOffset=False, weight=1) """ end anchor locator """ locBuffer = locators.locMeObject(segmentControls[-1]) attributes.storeInfo(locBuffer, 'cgmName', segmentControls[-1]) attributes.storeInfo(locBuffer, 'cgmTypeModifier', 'anchor') endAnchor = NameFactory.doNameObject(locBuffer) mc.setAttr((endAnchor + '.rotateOrder'), 5) mc.parent(endAnchor, spineIKHandle) #>>> set up follow chains constraintChain = [] constraintChain.append(hipsAnchor) constraintChain = constraintChain + vectorHandles constraintChain.append(endAnchor) constraintChainReturn = constraints.doSegmentAimPointConstraint( constraintChain) print constraintChainReturn vectorHandlesZeroGroups = [] for obj in vectorHandles: vectorHandlesZeroGroups.append(rigging.zeroTransformMeObject(obj)) """ parent the last group to our IK handle """ #mc.parent(vectorHandlesZeroGroups[-1],spineIKHandle) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Joint Chains #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ surface chain """ dupJointsBuffer = mc.duplicate(skinJoints[:-1], po=True, rc=True) surfaceJoints = [] for joint in dupJointsBuffer: attributes.storeInfo(joint, 'cgmType', 'surfaceJoint') surfaceJoints.append(NameFactory.doNameObject(joint)) """ firm start """ startJointsBuffer = mc.duplicate(skinJoints[0], po=True, rc=True) startJoints = [] for joint in startJointsBuffer: attributes.storeInfo(joint, 'cgmType', 'deformationJoint') startJoints.append(NameFactory.doNameObject(joint)) """ firm end """ endJointsBuffer = mc.duplicate(skinJoints[-2:], po=True, rc=True) endJoints = [] for joint in endJointsBuffer: attributes.storeInfo(joint, 'cgmType', 'deformationJoint') endJoints.append(NameFactory.doNameObject(joint)) mc.parent(endJoints[0], world=True) #>>> Influence chain """ get the root joints from our main chain searching by "cgmName" tags...maybe not the best way Maybe should change to search to closest joints """ influenceJointsBuffer = [] for obj in surfaceJoints: if (search.returnTagInfo(obj, 'cgmName')) != False: influenceJointsBuffer.append(obj) """ make our influence joints """ influenceJoints = [] for joint in influenceJointsBuffer: buffer = mc.duplicate(joint, po=True) closestObject = distance.returnClosestObject(buffer[0], surfaceJoints) attributes.storeInfo(buffer[0], 'cgmName', closestObject) attributes.storeInfo(buffer[0], 'cgmType', 'influenceJoint') rigging.doParentToWorld(buffer[0]) influenceJoints.append(NameFactory.doNameObject(buffer[0])) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Put our deformation joints in the rig #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ############### need better way of doing this for iterative mc.parent(endJoints[0], spineIKHandle) mc.parent(startJoints[0], hips) mc.parent(influenceJoints[0], hipsAnchor) mc.parent(influenceJoints[1], vectorHandles[0]) mc.parent(influenceJoints[2], spineIKHandle) #mc.parent(influenceJoints[3],spineIKHandle) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Control Surface #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ create """ orientationBuffer = list(jointOrientation) outChannel = orientationBuffer[2] upChannel = (orientationBuffer[1] + 'up') print upChannel surfaceBuffer = joints.loftSurfaceFromJointList(surfaceJoints, outChannel) controlSurface = surfaceBuffer[0] attributes.copyUserAttrs(moduleNull, controlSurface, attrsToCopy=['cgmName']) attributes.storeInfo(controlSurface, 'cgmType', 'controlSurface', True) controlSurface = NameFactory.doNameObject(controlSurface) """ connect joints to surface""" surfaceConnectReturn = joints.attachJointChainToSurface( surfaceJoints, controlSurface, jointOrientation, upChannel, 'animCrv') print surfaceConnectReturn """ surface influence joints skinning""" surfaceSkinCluster = mc.skinCluster(influenceJoints, controlSurface, tsb=True, n=(controlSurface + '_skinCluster'), maximumInfluences=3, normalizeWeights=1, dropoffRate=1) #surfaceSkinCluster = mc.skinCluster (influenceJoints,controlSurface,tsb=True, n=(controlSurface+'_skinCluster'),maximumInfluences = 3, normalizeWeights = 1, dropoffRate=1,smoothWeights=.5,obeyMaxInfluences=True, weight = 1) controlSurfaceSkinCluster = surfaceSkinCluster[0] """ smooth skin weights """ skinning.simpleControlSurfaceSmoothWeights(controlSurface) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Connect skin joints to surface joints #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> deformationJoints = [] deformationJoints.append(startJoints[0]) deformationJoints = deformationJoints + surfaceJoints[1:-2] deformationJoints = deformationJoints + endJoints for joint in skinJoints: attachJoint = distance.returnClosestObject(joint, deformationJoints) pntConstBuffer = mc.pointConstraint(attachJoint, joint, maintainOffset=False, weight=1) orConstBuffer = mc.orientConstraint(attachJoint, joint, maintainOffset=False, weight=1) #mc.connectAttr((attachJoint+'.t'),(joint+'.t')) #mc.connectAttr((attachJoint+'.r'),(joint+'.r')) mc.connectAttr((attachJoint + '.s'), (joint + '.s')) pntConstBuffer = mc.pointConstraint(attachJoint, joint, maintainOffset=False, weight=1) orConstBuffer = mc.orientConstraint(attachJoint, joint, maintainOffset=False, weight=1)
def orientSegment(limbJoints, posTemplateObjects, orientation): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Basic limb skeletonizer ARGUMENTS: limbJoints(list) templeateObjects(list) orientation(string) - ['xyz','yzx','zxy','xzy','yxz','zyx'] RETURNS: limbJoints(list) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ """ orientation vectors""" orientationVectors = search.returnAimUpOutVectorsFromOrientation( orientation) wantedAimVector = orientationVectors[0] wantedUpVector = orientationVectors[1] """put objects in order of closeness to root""" limbJoints = distance.returnDistanceSortedList(limbJoints[0], limbJoints) #>>> Segment our joint list by names jointSegmentsList = [] cullList = [] """ gonna be culling items from the list so need to rebuild it, just doing a list1 = list2 somehow keeps the relationship....odd """ for obj in limbJoints: cullList.append(obj) while len(cullList) > 0: matchTerm = search.returnTagInfo(cullList[0], 'cgmName') objSet = search.returnMatchedTagsFromObjectList( cullList, 'cgmName', matchTerm) jointSegmentsList.append(objSet) for obj in objSet: cullList.remove(obj) #>>> get our orientation helpers helperObjects = [] for obj in posTemplateObjects: templateObj = attributes.returnMessageObject(obj, 'cgmName') helperObjects.append( attributes.returnMessageObject(templateObj, 'orientHelper')) #>>> un parenting the chain for joint in limbJoints[1:]: mc.parent(joint, world=True) #>>>per segment stuff cnt = 0 for segment in jointSegmentsList: if len(segment) > 1: """ creat our up object from from the helper object """ helperObjectCurvesShapes = mc.listRelatives(helperObjects[cnt], shapes=True) upLoc = locators.locMeCvFromCvIndex(helperObjectCurvesShapes[0], 30) print upLoc """ make a pair list""" pairList = lists.parseListToPairs(segment) for pair in pairList: """ set up constraints """ constraintBuffer = mc.aimConstraint(pair[1], pair[0], maintainOffset=False, weight=1, aimVector=wantedAimVector, upVector=wantedUpVector, worldUpVector=[0, 1, 0], worldUpObject=upLoc, worldUpType='object') mc.delete(constraintBuffer[0]) for obj in segment[-1:]: constraintBuffer = mc.orientConstraint(segment[-2], obj, maintainOffset=False, weight=1) mc.delete(constraintBuffer[0]) """ increment and delete the up loc """ cnt += 1 mc.delete(upLoc) else: helperObjectCurvesShapes = mc.listRelatives(helperObjects[cnt], shapes=True) upLoc = locators.locMeCvFromCvIndex(helperObjectCurvesShapes[0], 30) """ make an aim object """ aimLoc = locators.locMeObject(helperObjects[cnt]) aimLocGroup = rigging.groupMeObject(aimLoc) mc.move(10, 0, 0, aimLoc, localSpace=True) constraintBuffer = mc.aimConstraint(aimLoc, segment[0], maintainOffset=False, weight=1, aimVector=wantedAimVector, upVector=wantedUpVector, worldUpVector=[0, 1, 0], worldUpObject=upLoc, worldUpType='object') mc.delete(constraintBuffer[0]) mc.delete(aimLocGroup) mc.delete(upLoc) cnt += 1 #>>>reconnect the joints pairList = lists.parseListToPairs(limbJoints) for pair in pairList: mc.parent(pair[1], pair[0]) """ Freeze the rotations """ mc.makeIdentity(limbJoints[0], apply=True, r=True) return limbJoints
def skeletonize(moduleNull, stiffIndex=0): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Basic limb skeletonizer ARGUMENTS: moduleNull(string) stiffIndex(int) - the index of the template objects you want to not have roll joints For example, a value of -1 will let the chest portion of a spine segment be solid instead of having a roll segment. Default is '0' which will put roll joints in every segment RETURNS: limbJoints(list) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>>Get our info #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> partName = NameFactory.returnUniqueGeneratedName(moduleNull, ignore='cgmType') """ template null """ templateNull = modules.returnTemplateNull(moduleNull) templateNullData = attributes.returnUserAttrsToDict(templateNull) """ template object nulls """ templatePosObjectsInfoNull = modules.returnInfoTypeNull( moduleNull, 'templatePosObjects') templateControlObjectsNull = modules.returnInfoTypeNull( moduleNull, 'templateControlObjects') templatePosObjectsInfoData = attributes.returnUserAttrsToDict( templatePosObjectsInfoNull) templateControlObjectsData = attributes.returnUserAttrsToDict( templateControlObjectsNull) jointOrientation = modules.returnSettingsData('jointOrientation') moduleRootBuffer = modules.returnInfoNullObjects(moduleNull, 'templatePosObjects', types='templateRoot') moduleRoot = moduleRootBuffer[0] stiffIndex = templateNullData.get('stiffIndex') rollJoints = templateNullData.get('rollJoints') """ AutonameStuff """ divider = NameFactory.returnCGMDivider() skinJointsNull = modules.returnInfoTypeNull(moduleNull, 'skinJoints') templateObjects = [] coreNamesArray = [] #>>>TemplateInfo for key in templatePosObjectsInfoData.keys(): if (mc.attributeQuery(key, node=templatePosObjectsInfoNull, msg=True)) == True: templateObjects.append(templatePosObjectsInfoData[key]) coreNamesArray.append(key) posTemplateObjects = [] """ Get the positional template objects""" for obj in templateObjects: bufferList = obj.split(divider) if (typesDictionary.get('templateObject')) in bufferList: posTemplateObjects.append(obj + divider + typesDictionary.get('locator')) """put objects in order of closeness to root""" posTemplateObjects = distance.returnDistanceSortedList( moduleRoot, posTemplateObjects) curve = (templatePosObjectsInfoData['curve']) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Actually making the skeleton with consideration for roll joints and the stiffIndex! #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if stiffIndex == 0: """ If no roll joints """ limbJoints = joints.createJointsFromCurve(curve, partName, rollJoints) else: rolledJoints = joints.createJointsFromCurve(curve, partName, rollJoints) if rollJoints == 0: limbJoints = rolledJoints else: if stiffIndex < 0: """ Get our to delete number in a rolledJoints[-4:] format""" #searchIndex = (int('%s%s' %('-',(rollJoints+1)))*abs(stiffIndex)-1) searchIndex = (int('%s%s' % ('-', (rollJoints + 1))) * abs(stiffIndex)) toDelete = rolledJoints[searchIndex:] """ delete out the roll joints we don't want""" mc.delete(toDelete[0]) for name in toDelete: rolledJoints.remove(name) """ make our stiff joints """ jointPositions = [] if abs(stiffIndex) == 1: jointPositions.append( distance.returnClosestUPosition( posTemplateObjects[stiffIndex], curve)) else: for obj in posTemplateObjects[stiffIndex:]: jointPositions.append( distance.returnClosestUPosition(obj, curve)) stiffJoints = joints.createJointsFromPosListName( jointPositions, 'partName') """ connect em up """ mc.parent(stiffJoints[0], rolledJoints[-1]) limbJoints = [] for joint in rolledJoints: limbJoints.append(joint) for joint in stiffJoints: limbJoints.append(joint) else: """ if it's not negative, it's positive....""" searchIndex = ((rollJoints + 1) * abs(stiffIndex)) toDelete = rolledJoints[:searchIndex] toKeep = rolledJoints[searchIndex:] """ delete out the roll joints we don't want""" mc.parent(toKeep[0], world=True) mc.delete(toDelete[0]) for name in toDelete: rolledJoints.remove(name) """ make our stiff joints """ jointPositions = [] if abs(stiffIndex) == 1: jointPositions.append( distance.returnClosestUPosition( posTemplateObjects[stiffIndex - 1], curve)) else: for obj in posTemplateObjects[:stiffIndex]: jointPositions.append( distance.returnClosestUPosition(obj, curve)) stiffJoints = joints.createJointsFromPosListName( jointPositions, 'partName') """ connect em up """ mc.parent(rolledJoints[0], stiffJoints[-1]) limbJoints = [] for joint in stiffJoints: limbJoints.append(joint) for joint in rolledJoints: limbJoints.append(joint) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Naming #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ Copy naming information from template objects to the joints closest to them copy over a cgmNameModifier tag from the module first """ attributes.copyUserAttrs(moduleNull, limbJoints[0], attrsToCopy=['cgmNameModifier']) """ First we need to find our matches """ for obj in posTemplateObjects: closestJoint = distance.returnClosestObject(obj, limbJoints) transferObj = attributes.returnMessageObject(obj, 'cgmName') """Then we copy it""" attributes.copyUserAttrs( transferObj, closestJoint, attrsToCopy=['cgmNameModifier', 'cgmDirection', 'cgmName']) limbJointsBuffer = NameFactory.doRenameHeir(limbJoints[0]) limbJoints = [] limbJoints.append(limbJointsBuffer[0]) for joint in limbJointsBuffer[1]: limbJoints.append(joint) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Orientation #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> limbJoints = orientSegment(limbJoints, posTemplateObjects, jointOrientation) #>>> Set its radius and toggle axis visbility on #averageDistance = distance.returnAverageDistanceBetweenObjects (limbJoints) jointSize = ( distance.returnDistanceBetweenObjects(limbJoints[0], limbJoints[-1]) / 6) for jnt in limbJoints: mc.setAttr((jnt + '.radi'), jointSize * .2) #>>>>>>> TEMP joints.toggleJntLocalAxisDisplay(jnt) print 'to orientation' #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Storing data #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> skinJointsNull = modules.returnInfoTypeNull(moduleNull, 'skinJoints') skinJointsNullData = attributes.returnUserAttrsToList(skinJointsNull) existingSkinJoints = lists.removeMatchedIndexEntries( skinJointsNullData, 'cgm') print existingSkinJoints if len(existingSkinJoints) > 0: for entry in existingSkinJoints: attrBuffer = (skinJointsNull + '.' + entry[0]) print attrBuffer attributes.doDeleteAttr(skinJointsNull, entry[0]) for i in range(len(limbJoints)): buffer = ('%s%s' % ('joint_', i)) attributes.storeInfo(skinJointsNull, buffer, limbJoints[i]) return limbJoints
def saveTemplateToModule(moduleNull): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: * Save the new positional information from the template objects * Collect all names of objects for a delete list * If anything in the module doesn't belong there, un parent it, report it * like a template object parented to another obect ARGUMENTS: moduleNull(string) RETURNS: limbJoints(list) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Variables #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Get our base info """ module null data """ moduleNullData = attributes.returnUserAttrsToDict(moduleNull) """ part name """ partName = NameFactory.returnUniqueGeneratedName(moduleNull, ignore = 'cgmType') partType = moduleNullData.get('cgmModuleType') direction = moduleNullData.get('cgmDirection') """ template null """ templateNull = moduleNullData.get('templateNull') templateNullData = attributes.returnUserAttrsToDict(templateNull) """ template object nulls """ templatePosObjectsInfoNull = returnInfoTypeNull(moduleNull,'templatePosObjects') templatePosObjectsInfoData = attributes.returnUserAttrsToDict (templatePosObjectsInfoNull) templateControlObjectsNull = returnInfoTypeNull(moduleNull,'templateControlObjects') templateControlObjectsData = attributes.returnUserAttrsToDict (templateControlObjectsNull) """ rig null """ rigNull = moduleNullData.get('rigNull') """ Start objects stuff """ templateStarterDataInfoNull = returnInfoTypeNull(moduleNull,'templateStarterData') templateControlObjectsDataNull = returnInfoTypeNull(moduleNull,'templateControlObjectsData') """ AutonameStuff """ divider = NameFactory.returnCGMDivider() moduleRootBuffer = returnInfoNullObjects(moduleNull,'templatePosObjects',types='templateRoot') moduleRoot = moduleRootBuffer[0] templateObjects = [] coreNamesArray = [] #>>>TemplateInfo for key in templatePosObjectsInfoData.keys(): if (mc.attributeQuery (key,node=templatePosObjectsInfoNull,msg=True)) == True: templateObjects.append (templatePosObjectsInfoData[key]) coreNamesArray.append (key) posTemplateObjects = [] """ Get the positional template objects""" for obj in templateObjects: bufferList = obj.split(divider) if (typesDictionary.get('templateObject')) in bufferList: posTemplateObjects.append(obj) """ get our control template objects """ controlTemplateObjects=[] for key in templateControlObjectsData.keys(): if (mc.attributeQuery (key,node=templateControlObjectsNull,msg=True)) == True: controlTemplateObjects.append (templateControlObjectsData[key]) """put objects in order of closeness to root""" posTemplateObjects = distance.returnDistanceSortedList(moduleRoot,posTemplateObjects) controlTemplateObjects = distance.returnDistanceSortedList(moduleRoot,controlTemplateObjects) curve = (templatePosObjectsInfoData['curve']) #>>> get our orientation helpers helperObjects = [] for obj in posTemplateObjects: helperObjects.append(attributes.returnMessageObject(obj,'orientHelper')) masterOrient = (attributes.returnMessageObject(moduleRoot,'orientHelper')) print ('%s%s'% (moduleNull,' data acquired...')) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Save Data #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Get the data """ pos objects """ storageData = [] for obj in posTemplateObjects: storageData.append(mc.xform (obj, q=True, ws=True, sp=True)) """ orientation helpers """ for obj in helperObjects: storageData.append(mc.xform (obj, q=True, os=True, ro=True)) storageData.append(mc.xform (masterOrient, q=True, os=True, ro=True)) print storageData """ template control objects data""" tempateControlObjectsStorageData = [] for obj in controlTemplateObjects: print obj tempateControlObjectsStorageData.append(mc.xform (obj, q=True, ws=True, t=True)) tempateControlObjectsStorageData.append(mc.xform (obj, q=True, os=True, ro=True)) rootScale = (mc.xform (moduleRoot, q=True, relative = True, scale=True)) objScaleBuffer = (mc.xform (obj, q=True, relative = True, scale=True)) objScale = [] cnt = 0 for scale in objScaleBuffer: objScale.append(scale*rootScale[cnt]) cnt+=1 tempateControlObjectsStorageData.append(objScale) print tempateControlObjectsStorageData #>>> Store the data to the initial objects pos """ Get the attributes to store to""" initialObjectsTemplateDataBuffer = attributes.returnUserAttrsToList(templateStarterDataInfoNull) initialObjectsPosData = lists.removeMatchedIndexEntries(initialObjectsTemplateDataBuffer,'cgm') """ store it""" cnt=0 for set in initialObjectsPosData: attrBuffer = set[0] xBuffer = (templateStarterDataInfoNull+'.'+attrBuffer+'X') yBuffer = (templateStarterDataInfoNull+'.'+attrBuffer+'Y') zBuffer = (templateStarterDataInfoNull+'.'+attrBuffer+'Z') dataSet = storageData[cnt] mc.setAttr (xBuffer, dataSet[0]) mc.setAttr (yBuffer, dataSet[1]) mc.setAttr (zBuffer, dataSet[2]) cnt+=1 #>>> Store the data to the initial objects pos """ Get the attributes to store to""" templateControlObjectsDataNullBuffer = attributes.returnUserAttrsToList(templateControlObjectsDataNull) templateControlObjectsData = lists.removeMatchedIndexEntries(templateControlObjectsDataNullBuffer,'cgm') """ store it""" cnt=0 for set in templateControlObjectsData: attrBuffer = set[0] xBuffer = (templateControlObjectsDataNull+'.'+attrBuffer+'X') yBuffer = (templateControlObjectsDataNull+'.'+attrBuffer+'Y') zBuffer = (templateControlObjectsDataNull+'.'+attrBuffer+'Z') dataSet = tempateControlObjectsStorageData[cnt] mc.setAttr (xBuffer, dataSet[0]) mc.setAttr (yBuffer, dataSet[1]) mc.setAttr (zBuffer, dataSet[2]) cnt+=1 #>>>>>>need to add locking>>>>>>>>>>>>>>>>>>>>>>>>>>>> print ('%s%s'% (moduleNull,' template object positional/rotational/scale data stored...')) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Save skin joints to skin joints null #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Delete stuff #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ Gather our objects""" toDeleteList = search.returnObjectsOwnedByModuleNull(templateNull) print toDeleteList for obj in toDeleteList: if mc.objExists(obj) == True: print ('%s%s'% (obj,' deleted...')) mc.delete(obj) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Change Tag #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> mc.setAttr ((moduleNull+'.templateState'), 0) mc.setAttr ((moduleNull+'.skeletonState'), 1) #add locking print ('%s%s'% (moduleNull,' done')) return 'done'
def getGeneratedInitialPositionData(self, PuppetInstance, startLocList, *a, **kw): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Calculates initial positioning info for objects ARGUMENTS: sourceObjects(list) visAttr(string) PuppetInstance.templateSizeObjects['start'],PuppetInstance.templateSizeObjects['end'] RETURNS: returnList(list) = [posList(list),endChildLoc(loc)] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ guiFactory.report("Generating Initial position data via Limb - '%s'" % self.ModuleNull.nameBase) partBaseDistance = kw.pop('partBaseDistance', 1) startLoc = startLocList[0] #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Distances #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ measure root object""" absStartCurveSize = distance.returnAbsoluteSizeCurve( PuppetInstance.templateSizeObjects['start']) sizeObjectLength = distance.returnDistanceBetweenObjects( startLoc, PuppetInstance.templateSizeObjects['end']) corePositionList = modules.returncgmTemplatePartPositionData( self.afModuleType.value) or False if not corePositionList: corePositionList = [] positions = cgmMath.divideLength(1, self.optionHandles.value) for position in positions: bufferList = [0, 0] bufferList.append(position) corePositionList.append(bufferList) guiFactory.report("Core position list %s" % corePositionList) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Things with the character root as a base Limb segments and Torsos #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if not self.moduleParent: """ Get the data in a usable format. Our positional ratios are stored in x,y,z format so we're going to get the absolute size data in that format with our distance being our z value """ moduleSizeBaseDistanceValues = [] moduleSizeBaseDistanceValues.append(absStartCurveSize[0]) moduleSizeBaseDistanceValues.append(absStartCurveSize[2]) moduleSizeBaseDistanceValues.append(sizeObjectLength) """ multiply our values """ translationValues = [] for list in corePositionList: translationValues.append( cgmMath.multiplyLists([list, moduleSizeBaseDistanceValues])) baseLocs = [] for value in translationValues: locBuffer = mc.duplicate(startLoc) mc.xform(locBuffer, t=value, r=True, os=True) baseLocs.append(locBuffer[0]) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # SubSplitting #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> splitTransformationValues = [] if self.optionStiffIndex.value != 0: if self.optionHandles.value > len(baseLocs): if self.optionStiffIndex.value > 0: stiff = 'positive' splitDistance = distance.returnDistanceBetweenObjects( baseLocs[self.optionStiffIndex.value], baseLocs[-1]) print splitDistance print baseLocs[self.optionStiffIndex.value] positions = cgmMath.divideLength( splitDistance, (self.optionHandles.value - len(baseLocs) + 2)) for position in positions[1:-1]: splitTransformationValues.append([0, 0, position]) else: stiff = 'negative' splitDistance = distance.returnDistanceBetweenObjects( baseLocs[0], baseLocs[self.optionStiffIndex.value + -1]) positions = cgmMath.divideLength( splitDistance, (self.optionHandles.value - len(baseLocs) + 2)) for pos in positions[1:-1]: splitTransformationValues.append([0, 0, pos]) else: if self.optionHandles.value > len(baseLocs): stiff = 'zero' splitDistance = distance.returnDistanceBetweenObjects( baseLocs[0], baseLocs[1]) positions = cgmMath.divideLength( splitDistance, (self.optionHandles.value - len(baseLocs) + 2)) for pos in positions[1:-1]: splitTransformationValues.append([0, 0, pos]) if len(splitTransformationValues) > 0: for value in splitTransformationValues: if stiff == 'positive': locBuffer = mc.duplicate(baseLocs[stiffIndex]) else: locBuffer = mc.duplicate(baseLocs[0]) mc.xform(locBuffer, t=value, r=True, os=True) baseLocs.append(locBuffer[0]) baseLocs = distance.returnDistanceSortedList(startLoc, baseLocs) mc.delete(startLoc) posList = distance.returnWorldSpacePositionFromList(baseLocs) returnList = {} returnList['positions'] = posList returnList['locator'] = baseLocs[-1] for loc in baseLocs[:-1]: mc.delete(loc) guiFactory.report("Initial position list is %s" % returnList) return returnList else: """ Get the data in a usable format. Our positional ratios are stored in x,y,z format so we're going to get the absolute size data in that format with our distance being our z value """ moduleSizeBaseDistanceValues = [] moduleSizeBaseDistanceValues.append(absStartCurveSize[0]) moduleSizeBaseDistanceValues.append(absStartCurveSize[2]) moduleSizeBaseDistanceValues.append(sizeObjectLength) """ multiply our values """ translationValues = [] for list in corePositionList: translationValues.append( cgmMath.multiplyLists([list, moduleSizeBaseDistanceValues])) baseLocs = [] if partType == 'clavicle' and direction == 'left': for value in translationValues: locBuffer = mc.duplicate(startLoc) mc.xform(locBuffer, t=[-value[0], value[1], value[2]], r=True, os=True) baseLocs.append(locBuffer[0]) else: for value in translationValues: locBuffer = mc.duplicate(startLoc) mc.xform(locBuffer, t=value, r=True, os=True) baseLocs.append(locBuffer[0]) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # SubSplitting #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> splitTransformationValues = [] if stiffIndex != 0: if handles > len(baseLocs): if stiffIndex > 0: stiff = 'positive' splitDistance = distance.returnDistanceBetweenObjects( baseLocs[stiffIndex], baseLocs[-1]) print splitDistance print baseLocs[stiffIndex] positions = cgmMath.divideLength( splitDistance, (handles - len(baseLocs) + 2)) for position in positions[1:-1]: splitTransformationValues.append([0, 0, position]) else: stiff = 'negative' splitDistance = distance.returnDistanceBetweenObjects( baseLocs[0], baseLocs[stiffIndex + -1]) positions = cgmMath.divideLength( splitDistance, (handles - len(baseLocs) + 2)) for position in positions[1:-1]: splitTransformationValues.append([0, 0, position]) else: if handles > len(baseLocs): stiff = 'zero' splitDistance = distance.returnDistanceBetweenObjects( baseLocs[0], baseLocs[1]) positions = cgmMath.divideLength(splitDistance, (handles - len(baseLocs) + 2)) for position in positions[1:-1]: splitTransformationValues.append([0, 0, position]) if len(splitTransformationValues) > 0: for value in splitTransformationValues: if stiff == 'positive': locBuffer = mc.duplicate(baseLocs[stiffIndex]) else: locBuffer = mc.duplicate(baseLocs[0]) mc.xform(locBuffer, t=value, r=True, os=True) baseLocs.append(locBuffer[0]) baseLocs = distance.returnDistanceSortedList(startLoc, baseLocs) mc.delete(startLoc) posList = distance.returnWorldSpacePositionFromList(baseLocs) if partType == 'clavicle': posList.reverse() returnList = {} returnList['positions'] = posList returnList['locator'] = baseLocs[-1] for loc in baseLocs[:-1]: mc.delete(loc) print "Initial position list is %s" % returnList return returnList