Maya API - Python out Point Array

So I’m trying to generate a output of points, in my case vectors, (X,Y,Z) and want to create as many or as few of them as the plugin internal code requires.

So I started with this:

numAttr = OpenMaya.MFnArrayAttrsData()
myNode.OutRaysArr = numAttr.create()

and that works until you get here :

myNode.addAttribute ( myNode.OutRaysArr )

and this is what I get :

// Error: line 1: (kInvalidParameter): Object is incompatible with this method
# Traceback (most recent call last):
#   File "myNode.py", line 704, in myNodeInitializer
#     myNode.addAttribute ( myNode.OutRaysArr )
# RuntimeError: (kInvalidParameter): Object is incompatible with this method // 
// Warning: line 1: Failed to call script creator function // 

what am I missing, I know I have to somehow tell it what kinds of “objects” I want to store in there, but the num.Attr.create() only takes one argument, and that would be “this” / “self”.

Any examples in python where you have outgoing connections to multiple outgoing points, or objects would be great !

After some hacking I think I found my error, you can’t add anything other than MFnNumericParameters as connections, so here’s where I am so far :

numAttr = OpenMaya.MFnNumericAttribute()
myNode.OutRaysArr = numAttr.createAddr("outRaysArray", "ora")
numAttr.setWritable(0)
numAttr.setStorable(0)

I guess I’m looking for something similar to this, but with vectors

Here’s a link on how to build that compound attribute, the issue I can see for my purposes is I need it to be dynamic, and since it lives in a whole different section of code than the rest of the plugin, it’s not possible, unless I hard code the number of slots I’ll need and at that point I might as well use straight up Outputs.

Compound Attributes

I remember I was able to make a dynamic attribute similar to what you’re after that would be able to take N number of elements on the fly. I’ll try to dig it up for you!