poplalog.blogg.se

Maya python setattr with wildcard
Maya python setattr with wildcard










  1. #Maya python setattr with wildcard skin#
  2. #Maya python setattr with wildcard code#

# tell the weights attribute which vertex id it represents # the value is another dictionary whose key is the influence id and # the weights are stored in dictionary, the key is the vertId, # get the MPlug for the weightList and weights attributes InfId = int(skinFn.indexForInfluenceObject(infDags)) # create a dictionary whose key is the MPlug indice id and SkinFn = OpenMayaAnim.MFnSkinCluster(clusterNode)

#Maya python setattr with wildcard code#

So here is some example code to query weights: Now you know which influence is associated with which index returned by the MPlug. MFnSkinCluster.indexForInfluenceObject returns the setAttr index for the given dag path of an influence. However, to be useful, we need these indices to match up with specific influences.

#Maya python setattr with wildcard skin#

Technically a zero value could exist, but unless you set it manually that shouldn't happen for skin weights (and could bloat your file size if you went around setting a bunch of zeroes). MPlug.getExistingArrayAttributeIndices returns the indices of these non-zero weights. The great thing for skin weights is maya only "activates" the influence ids in this weights attribute that are non-zero for the vertex. There is an attribute on the skinCluster called weightList, whose index is the vertex id, which has a child attribute called weights, whose index is the influence id, which stores the weight value. The fastest and most python friendly way to query a skinCluster's weights (that I know about) is to use MPlug. So if you are trying to iterate over the weights to modify, normalize, etc, python really starts to bog down. For each vertex it returns weights for all influences, and since most of these are zero, it is a lot of "useless" information python has to iterate over. However, what it returns back is not a good way to work with weights in python. People will often bring up MFnSkinCluster.getWeights since it is technically the fastest method to query a dense mesh with lots of influences. those commands that are appreciably slowed, like ls and listRelatives, we will be rewritten using python api so that we can have greater speed, more options including iterators, and to rid ourselves of the memory leak in ls on maya 2008.There are a lot of things you can do to speed up the query and set of skinCluster weights in Maya, but you do have to delve into the API and deal with more complex code. Imho, speed is such a small tradeoff for the usability that pymel provides. and then if you're still not satisfied, you'll have to use a third party wrapper like pymel, or write your own. So the best we can do is to report the big bugs and the big usability issues (like ls returning None instead of an empty list). it would be poor planning on autodesk's part to provide python as a scripting language in its current incarnation, give people a year or two to begin porting over to it, and then completely change it again. i'm pretty sure that we're stuck with what we have - as far as autodesk is concerned, they've added a new feature to maya's toolset and it's time to move on. only autodesk can do this because they have all the source code already, but if they were going to create a more pythonic implementation of mel, i think that they would have done it already. pymel would not exist if autodesk had done this in the first place, but for an end-user to rewrite almost a thousand mel commands is out of the question. But to be honest the entire command set should be built anew with the c++ api to maximize python benefit. You said it should be simple in the title of your post. the primary point of pymel is to weed out this kind of idiotic syntax forced upon us by autodesk's explicit translation from mel to python. i don't think it's possible for an attribute to have multiple types. also, for some odd reason when querying the type with cmds.addAttr it returns the type in a list. when you get the attribute it's an array of vectors and not just a list of doubles. With pymel you don't have to specify the length of the array or do any other ridiculous mel holdovers. # Result: #Ĭmds.addAttr( 'persp.vecTest', q=1, dataType=1) # Result: ), Vector()] #ĪddAttr( 'persp.vecTest', q=1, dataType=1)Ĭmds.addAttr( 'persp', ln= 'vecTest', dt='vectorArray' )Ĭmds.setAttr( 'persp.vecTest', 2,, "",, type='vectorArray' ) Pymel has enhancements for setting, getting, and querying array types.ĪddAttr( 'persp', ln= 'vecTest', dt='vectorArray' )












Maya python setattr with wildcard