I'm new to Python. I was trying to convert the example, intersectOnNurbsSurfaceCmd.cpp, into Python code. When I got to the ns.intersect function, Maya complained. Can anyone else get this to work? I was using this example to learn. And eventually I want to be able to compute a nurbs intersection along a specific vector. Eventually, I'd like to write a plugin. I was using Python to prototype.
Yes, however remeber this is NOT a python api its just a wrapper to C++ api so its mostly just like wirting C++*. With a lot of extra hastle. Becaus ethere is no pointer types in python you will need to use the maya.OpenMaya.MScriptUtil()
function to generate appropriate objects, which is a big hastle. You need to use the Also python does omit the stat querries.
And eventually I want to be able to compute a nurbs intersection along a specific vector.
you do understand the the exsisting nodes can allready do this! But yes by all means.
so you get the worst of both worlds so to speak. But the cool thing about python is that you can reinstate the plugin code runtime.
I know existing nodes can do this. This is a learning exercise for me. I was told that Python API is faster than Mel. And that compiled code is even faster. I wanted to benchmark this for myself. I wrote a Mel version of what I wanted to test and timed it against a Python API version. Mel was faster. I was hoping the intersect function might speed things up but was unable to get it to work. Thanks for the tip on MScriptUtil. I'll look into it.
well no its not that, it works on faster methods but theres a lot of caveat at faster. Mel is actually faster than the C++ api in quite a bit of cases. The python scripting api (maya.cmds) IS MEL, just written in python, since theres some overhead running python its slower if you do the exact same thing.
The maya API on the otherhand is somewhat faster since ist more atomic. Theese things just dont traslate into same terms because they have different purposes tough. Theres not much point in translating one thing form one system to another IF you keep everything the same, its the algorithmic things, and in case of the C++ the compilers optimizer, that makes stuff faster. However changing things like this gets you just so far, better algorithms are the key for faster operation.
I was hoping the intersect function might speed things up but was unable to get it to work.
Err it dont exactly work that way. But yeah sure.
The typical slowdowns is doing the wrong thing with wrong module, so looping over a setAttr costruct is slow mainly because it builds up undo items, and theres a lot of validation going on. This si especially true if your calling mel in expressions, in which case its sure as hell is faster. But theangain calling pthon is expressions is just that very slow because your wrapping the wrong thing and doinga compile at every turn. That is unless your python was wrapped to be visible in mel as a mel commend (in which case theres just a little overhead)
Likewise here, if you intersect many things in one go its faster than if you intersect it many times separately. Becase maya caches the results in between. Offourse mel has no real choce on the matter for it its allways a separate operation.
I’m also experiencing this issue with intersection method in maya 2018 and it complains for the wrong attributes but i put everything according to python api
And i creating custom node just because i didn’t find a good way to get Ray intersection with surface by maya nodes
I would be really appreciate if you could provide an example