Thanks for the help Remi!

Your method didn't work for me right away but was a big help. Knowing that 
I can get any attribute I want inside the compute() without relying on the 
datablock being passed in was pivotal along with some of your other 
examples, like getting the children of the compound attribute. I had to use 
direct references to the MObjects themselves instead of indices, however.

In the end I used this and it mostly works, except that sometimes the 
IntArray attribute doesn't have any data in it, not sure why yet.

def compute(self, plug, dataBlock): 

if plug.attribute() == self.attrIn_blendWeight:
inputAttrs = [self.attrIn_tensionColor_01, self.attrIn_tensionIndex_01, self
.attrIn_blendWeight]
multiInputArrayHandle = dataBlock.inputArrayValue( 
self.attrIn_blendShapeMultiInput 
)

while not multiInputArrayHandle.isDone():
multiInputHandle = multiInputArrayHandle.inputValue()

tensionColorHandle = multiInputHandle.child( inputAttrs[0] )
tensionIndexHandle = multiInputHandle.child( inputAttrs[1] )
blendWeightHandle = multiInputHandle.child( inputAttrs[2] )

tensionColorData = tensionColorHandle.data()
tensionIndexData = tensionIndexHandle.data()

tensionColor = om.MFnDoubleArrayData( tensionColorData ).array()
try:
tensionIndex = om.MFnIntArrayData( tensionIndexData ).array()
except:
multiInputArrayHandle.next()
continue
blendWeight = blendWeightHandle.asFloat()

print tensionColor
print tensionIndex
print blendWeight

try:
rgbValues = self.sortRGB( tensionIndex, tensionColor )
print "Done", rgbValues
except:
print "Bad stuff"

# next!
multiInputArrayHandle.next()

On Wednesday, August 29, 2018 at 6:32:45 PM UTC-7, Michael Kato wrote:
>
> Hi all,
>
> I've having a load of trouble with this. I've managed to get some complex 
> (for me anyway) compound attributes set up and connected to objects in my 
> scene, but right now I'm unable to get the "Blend Shape Multi Input" 
> attribute to arrive as a plug to the compute() method in my scripted node. 
>
> So I resorted to some trickery by looking for the "blendWeight" attribute 
> instead when it changes, then getting om.MDataPlug.parent() which is the 
> compound node, then re-getting the children of that compound node and their 
> data. 
>
> My attributes look like this
>
> [image: node.PNG]
>
>
> All of this works except for one crucial thing, calling asMDataHandle()
> childData = childPlug.asMDataHandle().data()
>
> This seems to force the recompute of some things and sends my plugin into 
> an infinite loop. Is there a better way to do this?
>
> Code attached, it should work in maya 2018 (possibly earlier) in a scene 
> with some blendshapes in it if you call connectBlendShapeNodes()
>
> Thanks for any 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/a2978a97-b7d9-498f-be1a-af14ec6c7065%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to