def _fnc_skinCluster(self): self.log_toDo("Add ability to check exisiting targets skin") self.log_toDo("Add more than just skincluster ability?...") #.......................................................... _targetMesh = self.mData.d_target['mesh'] #...See if we have a skin cluster... _targetSkin = skinning.querySkinCluster(_targetMesh) or False if _targetSkin: if self._l_missingInfluences: self.log_info("Adding influences...") for infl in self._l_missingInfluences: try:mc.skinCluster(_targetSkin, edit = True, ai = infl) except Exception,err: log.error(err)
def validateMeshArg(self, mesh=None): ''' Validates a mesh and returns a dict of data :param mesh: mesh to evaluate ''' _mesh = None _skin = None if mesh is None: #if self.d_kws.get('sourceMesh'): #log.info("Using stored sourceMesh data") #sourceMesh = self.d_kws.get('sourceMesh') #else: log.info("No source specified, checking if selection found") _bfr = mc.ls(sl=True) if not _bfr: raise ValueError, "No selection found and no source arg" mesh = _bfr[0] _type = search.returnObjectType(mesh) if _type in ['mesh', 'nurbsCurve', 'nurbsSurface']: if _type in ['nurbsCurve', 'nurbsSurface']: raise NotImplementedError, "Haven't implemented nurbsCurve or nurbsSurface yet" log.info("Skinnable object '{0}', checking skin".format(mesh)) _mesh = mesh _skin = skinning.querySkinCluster(_mesh) or False if _skin: log.info("Found skin '{0}' on '{1}'".format(_skin, _mesh)) elif _type in ['skinCluster']: log.info("skinCluster '{0}' passed...".format(mesh)) _skin = mesh _mesh = attributes.doGetAttr(_skin, 'outputGeometry')[0] log.info("Found: {0}".format(_mesh)) else: raise ValueError, "Not a usable mesh type : {0}".format(_type) _shape = mc.listRelatives(_mesh, shapes=True, fullPath=False)[0] _return = { 'mesh': _mesh, 'meshType': _type, 'shape': _shape, 'skin': _skin, 'component': data._geoToComponent.get(_type, False), 'pointCount': mc.polyEvaluate(_shape, vertex=True) } return _return
def validateMeshArg(self, mesh = None): ''' Validates a mesh and returns a dict of data :param mesh: mesh to evaluate ''' _mesh = None _skin = None if mesh is None: #if self.d_kws.get('sourceMesh'): #log.info("Using stored sourceMesh data") #sourceMesh = self.d_kws.get('sourceMesh') #else: log.info("No source specified, checking if selection found") _bfr = mc.ls(sl=True) if not _bfr:raise ValueError,"No selection found and no source arg" mesh = _bfr[0] _type = search.returnObjectType(mesh) if _type in ['mesh', 'nurbsCurve', 'nurbsSurface']: if _type in ['nurbsCurve','nurbsSurface']: raise NotImplementedError, "Haven't implemented nurbsCurve or nurbsSurface yet" log.info("Skinnable object '{0}', checking skin".format(mesh)) _mesh = mesh _skin = skinning.querySkinCluster(_mesh) or False if _skin: log.info("Found skin '{0}' on '{1}'".format(_skin,_mesh)) elif _type in ['skinCluster']: log.info("skinCluster '{0}' passed...".format(mesh)) _skin = mesh _mesh = attributes.doGetAttr(_skin,'outputGeometry')[0] log.info("Found: {0}".format(_mesh)) else: raise ValueError,"Not a usable mesh type : {0}".format(_type) _shape = mc.listRelatives(_mesh,shapes=True,fullPath=False)[0] _return = {'mesh':_mesh, 'meshType':_type, 'shape':_shape, 'skin':_skin, 'component':data._geoToComponent.get(_type, False), 'pointCount':mc.polyEvaluate(_shape, vertex=True) } return _return
def _fnc_skinCluster(self): self.log_toDo("Add ability to check exisiting targets skin") self.log_toDo("Add more than just skincluster ability?...") #.......................................................... _targetMesh = self.mData.d_target['mesh'] #...See if we have a skin cluster... _targetSkin = skinning.querySkinCluster(_targetMesh) or False if _targetSkin: if self._l_missingInfluences: self.log_info("Adding influences...") for infl in self._l_missingInfluences: mc.skinCluster(_targetSkin, edit = True, ai = infl) #try:mc.delete(_targetSkin) #except:pass else: #...create our skin cluster _l_bind = copy.copy(self.l_jointsToUse) _l_bind.append(_targetMesh) _targetSkin = mc.skinCluster(_l_bind,tsb=True,n=(names.getBaseName(_targetMesh)+'_skinCluster'))[0] self.mData.d_target['skin'] = _targetSkin#...update the stored data self.log_info("Created '{0}'".format(_targetSkin) + cgmGeneral._str_subLine)
def _fnc_processInfluenceMode(self): ''' Sort out the joint data If joitn list is passed, try to use that, if not, Try skin cluster on target, cluster on source ''' _mode = self._influenceMode _l_configInfluenceList = self.get_ConfigJointList()#...get our config influence list self.l_configInfluenceList = _l_configInfluenceList#...store it _len_configList = len(_l_configInfluenceList) _targetMesh = self.mData.d_target['mesh'] #...See if we have a skin cluster... _targetSkin = skinning.querySkinCluster(_targetMesh) or False if _mode == 'config': _l_jointTargets = _l_configInfluenceList elif _mode == 'list': _l_joints = self.d_kws.get('jointList') if not _l_joints: return self._FailBreak_("jointList kw required. '{0}' influenceMode".format(_mode)) if not cgmValid.isListArg(_l_joints): return self._FailBreak_("jointList is not a list. '{0}' influenceMode".format(_mode)) if len(_l_joints) != len(_l_configInfluenceList): return self._FailBreak_("Non matching counts on target influences({0}) and config data({1}) | Cannot use '{2}' influenceMode".format(len(_l_joints),len(_l_configInfluenceList),_mode)) _l_jointTargets = _l_joints elif _mode == 'target': if not _targetSkin: return self._FailBreak_("Target mesh not skinned, cannot use '{0}' influenceMode".format(_mode)) _l_targetInfluences = mc.listConnections(_targetSkin+'.matrix') or [] if len(_l_targetInfluences) != len(_l_configInfluenceList): #for i,jnt in enumerate(_l_configInfluenceList): #try:_bfr = _l_targetInfluences[i] #except: # _bfr = False #self.log_info("{0} | Config: {1} | target: {2}".format(i,jnt,_bfr)) if self._b_addMissingInfluences: self._b_case_addMissingInfluences = True#...set our case else: return self._FailBreak_("Non matching counts on target influences({0}) and config data({1}) | Cannot use '{2}' influenceMode".format(len(_l_targetInfluences),len(_l_configInfluenceList),_mode)) _l_jointTargets = _l_targetInfluences elif _mode == 'source': if not self.mData.d_source: return self._FailBreak_("No source data found, cannot use '{0}' influenceMode".format(_mode)) _sourceSkin = skinning.querySkinCluster(self.mData.d_source['mesh']) or False _l_sourceInfluences = mc.listConnections(_sourceSkin+'.matrix') or [] if len(_l_sourceInfluences) != len(_l_configInfluenceList): return self._FailBreak_("Non matching counts on source influences({0}) and config data({1}) | Cannot use '{2}' influenceMode".format(len(_l_sourceInfluences),len(_l_configInfluenceList),_mode)) _l_jointTargets = _l_sourceInfluences if self._b_case_addMissingInfluences:#Missing Influence Add... self.log_info("addMissingInfluencesAttempt... "+ cgmGeneral._str_subLine) if _len_configList < len(_l_jointTargets): self.log_warning("More targetJoints({0}) than config joints({1}). Not implemented".format(len(_l_jointTargets),_len_configList)) else: _d = {} for i,v in enumerate(_l_jointTargets):_d[i] = v#...push stuff to a list for i,jnt in enumerate(_l_configInfluenceList): try:_bfr = _l_jointTargets[i] except: _l_search = [jnt, self.mData.d_sourceSkin['matrix'][i]] self.log_info("{0} | Config: {1} | missing joint. Attempting to find: {2}".format(i,jnt,_l_search)) for o in _l_search: foundJnt = cgmValid.objString(o, mayaType = _validObjTypes, noneValid=True)#...mayaType = 'joint', if foundJnt: _d[i] = foundJnt self._l_missingInfluences.append(foundJnt) self.log_info("Found {0}".format(foundJnt)) break return self._FailBreak_("{0} | Not able to fo find joint ({1})".format(i,jnt)) #...push back to our list _l_jointTargets = [] for i in range(_len_configList):_l_jointTargets.append(False) for i,v in _d.iteritems(): _l_jointTargets[i] = v #self.log_info("{0} | Config: {1} | target: {2}".format(i,jnt,_bfr)) #self.log_info("Joints to use....") #for i,j in enumerate(_l_jointsToUse): #self.log_info("{0} : {1} | config idxed to: {2}".format(i,j,_l_configInfluenceList[i])) #...see if they exist with no conflicts #_l_jointTargets = l_dataJoints#...this will change try:_l_jointsToUse = cgmValid.objStringList(_l_jointTargets,mayaType = _validObjTypes)#...mayaType = 'joint' except Exception,Error:return self._FailBreak_("influenceMode '{0}' joint check fail | {1}".format(_mode,Error)) self.l_jointsToUse = _l_jointsToUse