I accidentally deleted
component = geo2.component()

I do mean to iterate through the geometry. I want it to go through
each vertex and set the weights to [0.4, 0.2, 0.1, 0.3]
It still doesn't do anything when I change it to

while not geo2.isDone():
    ind = om.MIntArray()
    nor = False
    component = geo2.currentItem()
    point = geo2.position(om.MSpace.kWorld)
    doubleArray = om.MScriptUtil()
    doubleArray.createFromList([0.4, 0.2, 0.1, 0.3], 4)
    oldWgt = om.MDoubleArray()
    newWgt = om.MDoubleArray(doubleArray.asDoublePtr(), 0)
    skin2.setWeights(skinPath2, component, ind, newWgt, nor, oldWgt)
    geo2.next()

What am I writing wrong?


On Jun 20, 4:31 pm, Justin Israel <[email protected]> wrote:
> I don't really know if this is it or not, but did you want to use the
> geometry iterator? Right now your loop is performing the same actions every
> time for the length of the count. Also I am not sure where your "component"
> variable comes from. But:
>
> while not geo2.isDone():
>     ...
>     skin2.setWeights(skinPath2, geo2.currentItem(), ind, newWgt, nor,
> oldWgt)
>     geo2.next()
>
> Does that help at all? I didn't read too much into what the code all does.
> Just noticed this part.
>
>
>
>
>
>
>
> On Wed, Jun 20, 2012 at 12:41 PM, Serena Xu <[email protected]> wrote:
> > I'm trying to set all the weights on a skinned mesh to the same array
> > of values. When I run this script it doesn't change the weights.
> > Please let me know what my mistake is. Thank you!
>
> > import maya.OpenMaya as om
> > import maya.cmds as cmds
> > import maya.OpenMayaAnim as oma
>
> > om.MGlobal.clearSelectionList()
> > om.MGlobal.selectByName('skinCluster2')
>
> > sList = om.MSelectionList()
> > om.MGlobal.getActiveSelectionList(sList)
> > node2 = om.MObject()
> > sList.getDependNode( 0, node2)
>
> > skin2 = oma.MFnSkinCluster(node2)
> > skinPath2 = om.MDagPath()
> > index2 = 0
> > skin2.indexForOutputConnection(index2)
> > skin2.getPathAtIndex(index2,skinPath2)
>
> > geo2 = om.MItGeometry(skinPath2)
> > vertices = geo2.count()
>
> > for i in range(0, vertices):
> >    ind = om.MIntArray()
> >    nor = False
> >    point = geo2.position(om.MSpace.kWorld)
> >    doubleArray = om.MScriptUtil()
> >    doubleArray.createFromList([0.4, 0.2, 0.1, 0.3], 4)
> >    oldWgt = om.MDoubleArray()
> >    newWgt = om.MDoubleArray(doubleArray.asDoublePtr(), 0)
> >    print oldWgt
> >    skin2.setWeights(skinPath2, component, ind, newWgt, nor, oldWgt)
>
> > --
> > view archives:http://groups.google.com/group/python_inside_maya
> > change your subscription settings:
> >http://groups.google.com/group/python_inside_maya/subscribe

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to