PDA

View Full Version : Python Maya API MScriptUtil


ChapmanMs
12-07-2007, 04:19 AM
I’m trying to get a return from MPointarray.get(). I cannot seem to get scriptutil to properly create a double[][4] pointer. I've tried multiple ways to no avail. I can't get asDouble4Ptr() method to work properly any help would be amazing.

zanarkand
12-07-2007, 05:17 AM
Ya... MScriptUtil is not very well documented... do you *have* to get it as a double[][4]?
Otherwise, you can actually get the individual MPoint/values by:


import maya.OpenMaya
import array
pt = maya.OpenMaya.MPoint(1, 2, 3, 4)
arr = maya.OpenMaya.MPointArray()
arr.insert(pt, 0)
arr.insert(pt, 0)
arr.insert(pt, 0)
arr.length()

# access the values via MPoint
pt2 = maya.OpenMaya.MPoint()
pt2 = arr[0]
print pt2[0] + pt2[1] + pt2[2] + pt2[3]

# or you can also access the values element by element
print arr[0][0] + arr[1][1] + arr[0][2] + arr[1][3]


Hope that helps!

ChapmanMs
12-07-2007, 05:33 AM
Yea I know I can work around it :sad:. But I'm really looking to learn how to use MScriptUtil better because some many of maya's method calls need pointers and i can't seem to get multi arrays working. Thanks though , Thats how I will be doing it if nothing with MScriptUtil Turns up.

zanarkand
12-07-2007, 05:57 AM
I can get a normal 1d array working with MScriptUtil... but I tried looking at 2d array just now. No luck...

CGTalk Moderation
12-07-2007, 05:57 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.