Hey, I think the problem you are having is in your use of MScriptUtil. As per the docs, the pointer you generate from data stored in an instance of a script util is somewhat bound to that instance. When you create more pointers from more data, you invalidate the previous pointers. Here is an example that I think should work for you:
https://gist.github.com/1684064 In your example, you see that all the pointers before the last one have invalid values. In the example I have provided, a new MScriptUtil is used each time, and stored with the pointer so as not to lose the reference. -- justin On Tue, Jan 24, 2012 at 6:20 PM, smb3d <pixelscie...@gmail.com> wrote: > Ultimately I'm trying to create a scatter script. > > I'm using the mfnMesh.getPointAtUV to get a world position from U,V > values on a surface. When I use a single float2 pointer it works > great. The problem is that I want to generate an array of random U,V > values and iterate through this to find the world position for each > set of U,V values. I can't seem to figure out how to set up something > that will generate the correct pointers for each set of random U,V > values in my array. > > I tried something like this, but ptrAry four copies of the same > pointer. > > .... > ptrArray = [] > numObjs = 4 > util = OpenMaya.MScriptUtil() > > for obj in range(numObjs): > util.createFromList ([random.uniform(0,1), random.uniform(0,1)],2) > sys.__stdout__.write(('%s') %util) > ptrArray .append(util.asFloat2Ptr()) > .... > > I can see why this possibly wouldn't work, but I'm stumped as how to > do it correctly. > > -- > view archives: http://groups.google.com/group/python_inside_maya > change your subscription settings: > http://groups.google.com/group/python_inside_maya/subscribe > -- view archives: http://groups.google.com/group/python_inside_maya change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe