Python maya.cmds.skinPercent() Examples
The following are 7
code examples of maya.cmds.skinPercent().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
maya.cmds
, or try the search function
.
Example #1
Source File: test_cmt_skinio.py From cmt with MIT License | 6 votes |
def test_import_skin_on_selected_subset(self): file_path = self.get_temp_filename("temp.skin") skinio.export_skin(file_path, self.shape) cmds.skinPercent( self.skin, "{0}.vtx[0]".format(self.shape), transformValue=[(self.joint1, 0.1), (self.joint2, 0.2), (self.joint3, 0.7)], ) cmds.skinPercent( self.skin, "{0}.vtx[1]".format(self.shape), transformValue=[(self.joint1, 0.1), (self.joint2, 0.2), (self.joint3, 0.7)], ) cmds.select("{}.vtx[1]".format(self.shape)) skinio.import_skin(file_path, to_selected_shapes=True) skin = skinio.SkinCluster(self.skin) data = skin.gather_data() w1 = [0.1, 0.5, 0.5, 0.0, 0.5, 0.0, 0.9, 0.5] w2 = [0.2, 0.5, 0.5, 0.5, 0.5, 0.5, 0.1, 0.5] w3 = [0.7, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0] self.assertListAlmostEqual(w1, data["weights"]["joint1"]) self.assertListAlmostEqual(w2, data["weights"]["joint2"]) self.assertListAlmostEqual(w3, data["weights"]["joint3"])
Example #2
Source File: ui.py From maya-skinning-tools with GNU General Public License v3.0 | 5 votes |
def setWeights(self, data): """ Set the weights on the Maya vertex. :param list data: List of list with influences and weights data """ cmds.skinPercent(self.skinCluster, self.vertex, transformValue=data) # ----------------------------------------------------------------------------
Example #3
Source File: dm2skin.py From dm2skin with The Unlicense | 5 votes |
def dm2skin_getLargestInfluenceOnVert(vertex, skinCluster=None): """Given a vertex returns the largest influence in the provided skin cluster that acts upon it.""" if not skinCluster: return False vertInfs = cmds.skinCluster(skinCluster, q=True, inf=True) vertVals = cmds.skinPercent(skinCluster, vertex, q=True, value=True) return vertInfs[vertVals.index(max(vertVals))]
Example #4
Source File: test_cmt_skinio.py From cmt with MIT License | 5 votes |
def test_import_skin_sets_correct_data(self): file_path = self.get_temp_filename("temp.skin") skinio.export_skin(file_path, self.shape) cmds.skinPercent( self.skin, "{0}.vtx[0]".format(self.shape), transformValue=[(self.joint1, 0.1), (self.joint2, 0.2), (self.joint3, 0.7)], ) skinio.import_skin(file_path) self.test_skincluster_data_is_correct()
Example #5
Source File: ml_softWeights.py From ml_tools with MIT License | 5 votes |
def softSelectionSkinWeights(*args): model = mc.ls(sl=True, o=True) joints = mc.ls(model, type='joint') mc.select(joints, deselect=True) weights = getSoftSelectionWeights() if not model or not joints or not weights: raise RuntimeError('Select vertices followed by a joint') if len(joints) > 1: raise RuntimeError('Only one joint can be selected at a time') joint = joints[0] skin = utl.getSkinCluster(model[0]) if not skin: raise RuntimeError('Mesh must have an existing skinCluster') influences = mc.skinCluster(skin, query=True, influence=True) if joint not in influences: mc.skinCluster(skin, edit=True, addInfluence=joint, lockWeights=False, weight=0) for influence in influences: mc.skinCluster(skin, edit=True, influence=influence, lockWeights=False) for vertex, weight in weights.items(): mc.skinPercent(skin, vertex, transformValue=(joint, weight)) mc.select(joint) # ______________________ # - -/__ Revision History __/- - - - - - - - - - - - - - - - - - - - - - - - # # Revision 1: 2016-12-31 : Initial publish # # Revision 2: 2018-02-17 : Updating license to MIT.
Example #6
Source File: ui.py From maya-skinning-tools with GNU General Public License v3.0 | 4 votes |
def __init__(self, parent, vertex): Qt.QWidget.__init__(self, parent) # variables self.vertex = vertex self.mesh, _ = vertex.split(".", 1) self.skinCluster = skin.getSkinCluster(self.mesh) # get skinned data influences = cmds.skinPercent( self.skinCluster, vertex, query=True, transform=None ) values = cmds.skinPercent( self.skinCluster, vertex, query=True, value=True ) # order data data = zip(values, influences) data.sort() data.reverse() # create layout layout = Qt.QVBoxLayout(self) layout.setContentsMargins(3, 3, 3, 3) layout.setSpacing(3) # create divider divider = widgets.Divider(self) layout.addWidget(divider) # create label self.label = VertexLabelWidget(self, vertex) layout.addWidget(self.label) # create divider divider = widgets.Divider(self) layout.addWidget(divider) # create frame self.frame = VertexInfluencesWidget(self, self.skinCluster, data) self.frame.signal.connect(self.setWeights) layout.addWidget(self.frame) # connect influences toggle self.label.signal.connect(self.frame.displayInfluences) self.frame.warningSignal.connect(self.label.displayWarning) # force display self.frame.displayMaxInfluences() # ------------------------------------------------------------------------
Example #7
Source File: uExport.py From uExport with zlib License | 4 votes |
def LOD_transferWeights(meshes, jointsToRemove, jointToTransferTo, debug=1, pruneWeights=0.001, *args): ''' Original function by Charles Anderson @ Epic Games ''' for mesh in meshes: # Find the skin cluster for the current mesh cluster = findCluster(mesh) if debug: print "MESH: ", mesh print "CLUSTER: ", cluster # Prune weights on the current mesh if pruneWeights: cmds.skinPercent(cluster, mesh, prw=pruneWeights) # Find all of the current influences on the current skin cluster. meshInfluences = cmds.skinCluster(cluster, q=True, inf=True) #print "Current Influences: ", meshInfluences for joint in jointsToRemove: if joint in meshInfluences: #print "Current Joint: ", joint # If the jointToTransferTo is not already an influence on the current mesh then add it. currentInfluences = cmds.skinCluster(cluster, q=True, inf=True) if jointToTransferTo not in currentInfluences: cmds.skinCluster(cluster, e=True, wt=0, ai=jointToTransferTo) # Now transfer all of the influences we want to remove onto the jointToTransferTo. for x in range(cmds.polyEvaluate(mesh, v=True)): #print "TRANSFERRING DATA....." value = cmds.skinPercent(cluster, (mesh+".vtx["+str(x)+"]"), t=joint, q=True) if value > 0: cmds.skinPercent(cluster, (mesh+".vtx["+str(x)+"]"), tmw=[joint, jointToTransferTo]) # Remove unused influences currentInfluences = cmds.skinCluster(cluster, q=True, inf=True) #print "Current Influences: ", currentInfluences influencesToRemove = [] weightedInfs = cmds.skinCluster(cluster, q=True, weightedInfluence=True) #print "Weighted Influences: ", weightedInfs for inf in currentInfluences: #print "Influence: ", inf if inf not in weightedInfs: #print "Update Influences to Remove List: ", inf influencesToRemove.append(inf) #print "ToRemove Influences: ", influencesToRemove if influencesToRemove != []: for inf in influencesToRemove: cmds.skinCluster(cluster, e=True, ri=inf) ## UI RELATED ######################################################################## #event filter to grab and discern right/left click