Solved!
Finally I could understand the MScriptUtil ... I spent a sleepless
night, but worth it ... hehehe ... I was making some mistakes before
Ryan help me ... and even then I only understood after reading the
documentation by the hundredth time. There maybe other ways to do
this ... but this was the only one that worked in my various tests.
CODE
import maya.OpenMaya as om
#Create the light that holds the ramp
light = om.MFnVolumeLight()
light.create()
light.setLightShape(3)
#Get the MRampAtrribute at the penumbraRamp atribute
myRamp = om.MRampAttribute(light.penumbraRamp())
#Some variables
myIndexArray = om.MIntArray()
myPosArray = om.MFloatArray()
myValArray = om.MFloatArray()
myInterpArray = om.MIntArray()
#It's even 0
myIndexList = []
myPosList = []
myValList = []
myInterpList = []
#Def to get the entries
def myGetEntries():
get_util = om.MScriptUtil()
get_util.createIntArrayFromList(myIndexList, myIndexArray)
get_indexPtr = get_util.asIntPtr()
get_util.createFloatArrayFromList(myPosList, myPosArray)
get_posPtr = get_util.asFloatPtr()
get_util.createFloatArrayFromList(myValList, myValArray)
get_valPtr = get_util.asFloatPtr()
get_util.createIntArrayFromList(myInterpList, myInterpArray)
get_interpPtr = get_util.asIntPtr()
myRamp.getEntries(myIndexArray, myPosArray, myValArray,
myInterpArray)
return myIndexArray, myPosArray, myValArray, myInterpArray
myEntries = myGetEntries()
print myEntriess
#Def to get the Value At Position
def getValAtPos():
valAt_util = om.MScriptUtil()
valAt_util.createFromDouble(0.5)
valAtPtr = valAt_util.asFloatPtr()
myRamp.getValueAtPosition(0.5, valAtPtr)
myMainValue = valAt_util.getFloat(valAtPtr)
return myMainValue
myValAtPos = getValAtPos()
print myValAtPos
I'm very happy!!!
Many thanks again Ryan! And you guys for the great job in this group!
--
http://groups.google.com/group/python_inside_maya