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() outPointB.growArray(len(inPoints)) for i, in_pt in enumerate(inPoints): print(i, in_pt.x) outPointB.addElement(i).setFloat(float(in_pt.x)) outPointsH.set(outPointB) outPointsH.setAllClean() Full code with 4 approaches, only one works: https://pastebin.ubuntu.com/p/CZr7ytX9C6/ 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 ! -michal On Saturday, July 3, 2021 at 1:22:35 PM UTC+2 Marcus Ottosson wrote: > 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. > > On Sat, 3 Jul 2021 at 11:56, f.mi...@gmail.com <f.mi...@gmail.com> wrote: > >> 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. >> >> On Friday, July 2, 2021 at 11:30:24 AM UTC+2 Marcus Ottosson wrote: >> >>> 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? >>> >>> On Fri, 2 Jul 2021 at 10:01, f.mi...@gmail.com <f.mi...@gmail.com> >>> wrote: >>> >>>> 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. >>>> >>>> code: >>>> https://pastebin.ubuntu.com/p/ZyY52k2dTN/ >>>> >>>> -- >>>> 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 python_inside_m...@googlegroups.com. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/python_inside_maya/12fa9b5a-8dc0-4759-a16a-e9f597824436n%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/python_inside_maya/12fa9b5a-8dc0-4759-a16a-e9f597824436n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- >> 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 python_inside_m...@googlegroups.com. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/python_inside_maya/ad0c52b2-eb31-49ee-88c3-547e5f0cec21n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/python_inside_maya/ad0c52b2-eb31-49ee-88c3-547e5f0cec21n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- 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 python_inside_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a536fb29-8ceb-4a78-8687-25b21eb5e3den%40googlegroups.com.