Maya 2023 Very slow setting weight attrs

162 views
Skip to first unread message

mattschiller

unread,
Mar 10, 2023, 6:25:48 PM3/10/23
to Python Programming for Autodesk Maya
I am seeing extreme slow downs when getting/setting weights using point indexes in Maya 2023. Especially on getting, 100x slow downs. Using iomode improves setting weight speeds to close to 2022 speeds but does not help getting. Using open maya gets around this problem in 2023 but open maya and setAttr, used in this way, was the same speed in 2022 and below. 

In this example, getting the weights takes in the hundredths of second in 2022 and 3-5 seconds in 2023. Any one have a clue? Affects all updates of 2023.

import maya.cmds as mc
import time

mc.dgcontrol(iomode=True)

# Build a 30K point plane and cluster
geo = mc.polyPlane(sx=100, sy=300)[0]
cluster = mc.cluster(geo)[0]

# Weights
pnt_count = mc.polyEvaluate(geo, v=1)
weight_attr = f"{cluster}.wl[0].w[0:{pnt_count-1}]"

# Get weights
start_time = time.time()
weight_array = mc.getAttr(weight_attr)
print('GET Weights Time', time.time() - start_time)

# Set weights
start_time = time.time()
mc.setAttr(weight_attr, *weight_array)
print('SET Weights Time', time.time() - start_time)

mc.dgcontrol(iomode=False)

jakeh

unread,
Apr 4, 2025, 2:28:29 PMApr 4
to Python Programming for Autodesk Maya
Hey all,

Reviving an old thread here.. but was there any more information on this problem?
I'm encountering exactly the same issue in Maya 2024/2025. 

Thanks,
Jake

Matin Falahmanesh

unread,
Aug 23, 2025, 12:45:47 PMAug 23
to Python Programming for Autodesk Maya
Hi! I did something similar in C++ before, and it was pretty fast:


MSelectionList clusterSelList;
clusterSelList.add(clusterName+".weightList[0].weights");

MPlug clusterPlug;
status = clusterSelList.getPlug(0, clusterPlug);
if (!status){ MGlobal::displayError("Failed to get cluster plug!"); return status;}

MItMeshVertex vtxIter(meshPath);
vtxIter.reset();

for (; !vtxIter.isDone(); vtxIter.next()){
    int vtxIndex = vtxIter.index();
    double w = phiNew(vtxIndex);

    status = clusterPlug.elementByLogicalIndex(vtxIndex).setFloat(w);
    if (!status){ MGlobal::displayError("Failed to set cluster plug!"); return status;}
    phiNewDoubleArray.append(w);
}


I also remember prototyping this with the Python API 2.0, and it was pretty fast as well. The above code should be straightforward to convert to the Python API. Let me know if you run into any trouble.

Reply all
Reply to author
Forward
0 new messages