talk.bindpose.com has been shut down on the 6th of March 2021. You can read a bit more about it here.

You are currently reading an archived copy of the latest content, with all the usernames deleted.

Getting array values from an MPxNode plug ...

by user21 posted 14-05-2019 | 1 comment

Hi there!

It has gotten quiet around here. Too bad! Anyway, I'll try my luck! I have written a small Node to blend multiple Poses for my facial rig. As I have not yet gotten around to learning how to do it in C++, I built it in phyton.

It works, but it is super slow. So I am trying to optimize. One thing I'd like to try is to not iterate through every plug, but instead read the whole attr as a list in one go. is that even possible?

Here is an example: cls.poseWeight = nAttr.create("poseWeight", "pw", OpenMaya.MFnNumericData.kFloat, 0.0) nAttr.setStorable (1) nAttr.setCached (1) nAttr.setKeyable(1) nAttr.setArray(1) nAttr.setUsesArrayDataBuilder(1) cls.addAttribute(cls.poseWeight)

where I want an array of all the poseWeights.

Any help would be appreciated!

Cheers,

Alex

 

by user3 posted 03-06-2019

Hi Alex,

I had a real quick look through the API to see if that's possible at all, as I haven't ever done it myself, but it looks like there's nothing in either the MPlug or MDataHandle classes, or their array alternatives.

That being said, optimizing a python plugin is, unfortunately, not really a rewarding experience, as due to the Global Interpreter Lock your plugin will always be a bottleneck in the evaluation. That's why, python plugins are often used for prototyping, but when performance is required, there is no real way around C++.

That should not scare you, though, as if you are able to write plugins in python, I am sure that following some tutorials online (have a look at Chad Vernon's website, he has some courses as well) you will be able to write your plugins in C++ as well.

If you are still keen on trying to improve the performance of your python plugin, though, I'd say try using the python profiling libraries to identify where the slowdown is coming from. If it's just the API calls, then you are out of luck as there's nothing you can do about that, but there's a small chance it's due to your implementation, in which case you should be able to get a bit of an improvement.

I hope that helps!