Hi Enrico,
I’m not very acquainted with the API, and maybe I’m not understanding you correctly, but Python passes everything as references to other objects.
# This would pass `my_iterator` as reference to `maya_function`
maya_function(my_iterator)
If you could provide a short snippet of your issue, I might be able to help more.
Best,
Marcus
--
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/d5207b32-1472-4e51-90dd-fc4affbf4154%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
In addition to what Marcus said about passing the iterator instance, have you profiled your code to come to the conclusion that it is inefficient to create your iterator and function sets from within the function?
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODmmPnGLULsPD-sMu6-8YwJX2X4-HAPZbnVNsurDyfzxA%40mail.gmail.com.
x = 5
def double(x):
x *= 2
double(x)
print xdef printIndex(polyIter):
print polyIter.index()
while not polyIter.isDone():
printIndex(polyIter)
polyIter.next()In addition to what Marcus said about passing the iterator instance, have you profiled your code to come to the conclusion that it is inefficient to create your iterator and function sets from within the function?
On Jun 11, 2014 2:57 AM, "Marcus Ottosson" <konstr...@gmail.com> wrote:
Hi Enrico,
I’m not very acquainted with the API, and maybe I’m not understanding you correctly, but Python passes everything as references to other objects.
# This would pass `my_iterator` as reference to `maya_function` maya_function(my_iterator)If you could provide a short snippet of your issue, I might be able to help more.
Best,
Marcus
On 10 June 2014 14:58, Enrico Losavio <enrico...@gmail.com> wrote:
Hi everyone.I'm new to Maya Python API. I've been studying it since a couple of months and now I'm trying to write my first script (to be later adapted into a node).I'm writing a main function to iterate through a mesh, and a few secondary functions to retrieve certain information about it.The point is, everytime i call a function I have to recreate the iterators, function sets and everything i need in order to make it work. This seems a lot like a waste of code and of performances.Do you know if there is a way to pass the iterators or any Maya object to a function as pointers? I know python doesn't deal with pointers, but it would be so much easier. I've tried to look in the MScriptUtil documentation, but i couldn't find anything helpfulThanks for the help!
--
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+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d5207b32-1472-4e51-90dd-fc4affbf4154%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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+unsub...@googlegroups.com.
Hi
Python is a pass-by-value language. And it doesn't have pointers. That means everything you pass is a copy of the value. Now that might sound strange to some, thinking it isn't true part time. When you pass an immutable object like an int, it is obvious. But when you pass a list, what you are passing is a copy of the lost reference. That means that while you can't replace the symbol with a new list (no pointers) you can modify it's members and the same list is affected.
So in the case where you want to modify and object being passed in, either return the new value, or pass a custom object that has attributes that can be modified. This is why you can advance the iterator. You pass a copy of the reference and then call next.
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/03bf3e54-3547-446d-b865-1d30535bd6d1%40googlegroups.com.