Using MArrayDataBuilder in python API 2.0

Skip to first unread message

Jul 2, 2021, 5:01:51 AMJul 2
to Python Programming for Autodesk Maya
I need a simple DG node that uses connected mesh and copies vertex coordinates to output MPoint array.
I am having trouble with setting this array with MArrayDataBuilder. It ether always stays zero-length or grows on every compute().
This surely must be simple to do, but I'm stuck. Can anybody help ?
One important detail - I need this array to be made of compound points so that I can query individual coordinates as attributes.


Marcus Ottosson

Jul 2, 2021, 5:30:24 AMJul 2
Compound attributes always makes life hard. Does it behave any different with plain float attributes? I.e. can the problem be isolated to the compound attributes?

You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Jul 3, 2021, 6:56:19 AMJul 3
to Python Programming for Autodesk Maya
My initial goal was to be able to read specific vertex coordinates, for example in expressions. So If I want to connect to, say outPoints[3].outPointsX - then I think compound attributes are my only choice.

Marcus Ottosson

Jul 3, 2021, 7:22:35 AMJul 3
Sure, yes the end result can be compound attributes, but what I'm wondering is whether compound attributes are the root cause of the problem, or if it's elsewhere. As a test, if you were to replace the compound attribute with a float, does it still cause trouble? If so, then we know to look more closely into the compound attributes. If not, then we could strike that off. Either way, being one step closer to success.

Jul 5, 2021, 6:28:34 AMJul 5
to Python Programming for Autodesk Maya
Now I get it, Marcus. Good idea!
So I did test with floats and got some results. The exact same code with kFloat also fails, but I found something that works with kFloats (but not with Points).

Shortened version that works with kFloat:

    outPointsH = dataBlock.outputArrayValue(self.outPoints)
    outPointB = outPointsH.builder()
    for i, in_pt in enumerate(inPoints):
        print(i, in_pt.x)

Full code with 4 approaches, only one works:
My use case is very specific (and I will probably settle for something simpler), so I can live with floats instead of points.
Nevertheless I'd love to know how to dynamically set points array in API - this things always make me trouble.

thanks !
Reply all
Reply to author
0 new messages