For the sake of posterity, I had a further playaround to try slot in an 
alternative check, basically, instead of using the checkArrayExist call I 
instead checked for the expected attribute name in the results of list(), 
and if it was present, then checked for the length of the 
vector/double/stringArray to be nonzero (and didn't throw an error) before 
considering it present.

It's still bugging me that i can't get the function working mind you :P


On Thursday, October 25, 2012 12:46:29 PM UTC+8, Anthony Tan wrote:
>
> Just building a custom force node and one of the things I'm trying to do 
> is patch in some dynamic PP variables that should be wrapped up with the 
> .cvar.MPxFieldNode_mInputPPData reference. I can quite happily list all 
> the PP attrib names that are being picked up but I'm having some (okay, a 
> lot) of trouble trying to leverage the checkArrayExist method. 
>
> Don't suppose anyone has any suggestions on where else to hunt around in? 
> If there's a devkit example I've missed (I'm reading heavily off 
> dynExprField right now) or similar, would love to be pointed at it. Noting 
> of course, if this isn't strictly possible/sane/there's a better way, then 
> happy to be pointed in that direction too, not picky, more curious at this 
> stage.
>
>
> Here's the relevant code fragment (it's embedded in the compute() of a 
> custom field deriving from MPxFieldNode ):
>
> aInputPPData = OpenMayaMPx.cvar.MPxFieldNode_mInputPPData
> mhInputPPData = block.inputArrayValue(aInputPPData)
> mhInputPPData.jumpToElement(plugIndex)
> hInputPPData = mhInputPPData.inputValue() 
> dInputPPData = hInputPPData.data()
> inputPPData = OpenMaya.MFnArrayAttrsData(dInputPPData)
>
> # okay, this is fine, I'll get the list of names
> sys.stderr.write(inputPPData.list())
>
> # the docs say if i'm trying to use enum types, I should be using a 
> pointer 
> # to a short int.. okay. I can understand that. I think.
> msu = OpenMaya.MScriptUtil(OpenMaya.MFnArrayAttrsData.kVectorArray)
> fieldexists = inputPPData.checkArrayExist("fish",msu.asShortPtr())
>
> With the error being:
>
> # Traceback (most recent call last):
>
> # File 
> "C:/Users/tanantish/Documents/maya/2012-x64/plugins/simpleField2.py", line 
> 149, in compute
>
> # fieldexists = inputPPData.checkArrayExist("fish",msu.asShortPtr())
>
> # File 
> "c:\buildforge\Maya_2012_Win64_Build\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py",
>  
> line 3859, in checkArrayExist
>
> # TypeError: in method 'MFnArrayAttrsData_checkArrayExist', argument 3 of 
> type 'MFnArrayAttrsData::Type &' // 
>
>

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to