Numpy for maya 2019

I have a couple questions releating to Numpy -

First : Has anyone built Numpy for Maya 2019 ? I have searched far and wide and have found no results as of yet. Only Maya 2018 <

Second : If I use functions from a Numpy lib or other module for a commercial or distributable plug-in, do those then also need to be included in the plugin distibution and is there an additional license for that.

Thanks

1 Like

The numpy for Maya 2018 on Windows works for 2019. We’re using it at work.

Also, the numpy license is really short, pretty straightforward, and really permissive. I’m no lawyer, but what I see is, as long as you include that license text somewhere in your docs, you should be fine.

2 Likes

Thanks tFox - All installed ! and good to know about the license.

While I’ve got you , - has getRawPoints() been removed entirely now ? It’s not accessible through python in 19 and has been removed from the C++ API docs as far as I can tell.
I’m looking for the fastest way to get data into numpy arrays.

Hmm, I haven’t used getRawPoints() in a while, so I didn’t even realize it was gone. That always seemed a bit hack-ish to me anyway. The module I wrote uses the more consistent get methods to do the IO.

1 Like

Hey tfox,

Hope you’re well in these odd times.
Do you have an updated version of this script please ? As It is not working with maya 2019/20.

Thanks,
Joe

I’ve been using it just fine in Maya 2019 and 2020. What errors are you getting?

Hey Tyler,
I was just emailing you back. I had an old version that threw up some errors. I see you updated it and grabbed the latest off the github.
No errors now. I’m reading through it to make sure I understand how to use it.
I’m currently using

meshFn.getPoints(om.MSpace.kWorld)

of an object, creating a np array from that, doing some numpy magic and setting it back with

gen = (om.MPoint(x) for x in self.currentPos)
self.meshFn.setPoints(gen, om.MSpace.kWorld)

I’m hoping to use your script to bypass those timecoming elements.

It may be that i’m just not understanding how to pass in the right information into the inPtAttr.
If you wouldn’t mind explaining what the attr or how to find that plug, might look like for the point data for example, I should be on the right track.
Thanks again

First, this is API 1.0 ONLY. It looks like you’re trying to use api 2.0

There’s 2 sets of functions in that module mayaToNumpy/numpyToMaya and getNumpyAttr/setNumpyAttr

The first set is used to convert between OpenMaya and numpy arrays. The second set is for setting data directly to node attributes. Since you’re working with an MFnMesh, then you’ll want to use the first set like this to get the data:

mpoints = om.MPointArray()
meshFn.getPoints(mpoints)
points = mayaToNumpy(mpoints)

And like this to set the data:

mpoints = numpyToMaya(points, om.MPointArray)
meshFn.setPoints(mpoints)

Thanks Tyler.
1.0 solved my issues.

This is approx - 2.5 * faster and I suspect that will scale with the amount of data.

Great work on this script, and really appreciate the help