Input kDoubleArray not updating with MFnDoubleArrayData

Input kDoubleArray not updating with MFnDoubleArrayData

dan.norris.25
Contributor Contributor
1,088 Views
4 Replies
Message 1 of 5

Input kDoubleArray not updating with MFnDoubleArrayData

dan.norris.25
Contributor
Contributor

I’m writing two nodes. The first node(nodeA) has a kDoubleArray output and the other(nodeB) has a kDoubleArray input. Each output/input use MFnDoubleArrayData to work with the plug.

 

The problem is that when I connect nodeA to nodeB, nodeB gets and stores the array at the time of the connection but it won’t update after that. Even if nodeA is changing the array, nodeB plugs are marked dirty as expected, the deform method runs but the MDouble Array doesn’t change from its initial state.

 

NodeA is working as expected. Here is the code for setting the output plug.

outMapData = dataBlock.outputValue(ProximityMap.outputMap)
outDblFn = OpenMaya.MFnDoubleArrayData()
outDblObj = outDblFn.create(outputMap)
outMapData.setMObject(outDblObj)
outMapData.setClean()

 

If I tell nodeA to print an array version of ‘outDblObj’ before setting it clean it updates as expected.

 

NodeB is not working as expected but does not give me any errors. Here is the code for getting the input plug.

mapHandle = dataBlock.inputValue(MapToPP.inputMap)
inArrFn = OpenMaya.MFnDoubleArrayData(mapHandle.data())
currMap = inArrFn.array()
print(currMap)

 

When I make the connection between the nodes, nodeB updates properly. After that, nodeB updates but ‘currMap’ remains the same as it was when it was first set.

 

Has anybody else seen this happen? According to documentation this should all be written correctly and I’ve run out of things to try. Any suggestions would be appreciated.

Thanks

0 Likes
Accepted solutions (1)
1,089 Views
4 Replies
Replies (4)
Message 2 of 5

cheng_xi_li
Autodesk Support
Autodesk Support

Hi Dan,

 

I didn't see some obvious issues in your description. Could you send us your sample code for testing? 

 

Yours,

Li

0 Likes
Message 3 of 5

dan.norris.25
Contributor
Contributor

Hello, thanks for the response. 

I have created a shortened version of each of the nodes here:

GenericVtxMap(NodeA) is used for the output.

https://github.com/danNorrisRigging/vtxMaps/blob/master/GenericVtxMap

MapOperation(NodeB) is used for the input

https://github.com/danNorrisRigging/vtxMaps/blob/master/MapOperation

 

These are both deformers. Do the following steps to test:

  1. Create a polygon and apply both deformers
  2. Go into paint mode for 'GenericVtxMap1.inputMap' and flood all verts to 1.0
  3. Connect 'GenericVtxMap.outputMap' to 'MapToPP.inputMap'
  4. Check the script editor feedback, notice there are two arrays printing. Both arrays should be 1.0 on all.
  5. Flood the map to anything other than 1.0 
  6. Check the script editor feedback, notice the two arrays are different

Let me know if you need any other information. 

 

Thanks,

Dan

0 Likes
Message 4 of 5

cheng_xi_li
Autodesk Support
Autodesk Support
Accepted solution

Hi Dan,

 

Thanks for the sample. There are few issues in the original code without considering the issue you mentioned. So I made some fixes based on my understanding.

 

There are some issues might affect the results here:

1. Missing for affectAttributes for outputMap  

2. Setting arrayDataBuilder on inputMap isn't necessary

3. You don't need to return anything if it is kSuccess in Python.

 

After adding affectAttributes for outputMap, it is working fine now.

 

Yours,

Li

0 Likes
Message 5 of 5

dan.norris.25
Contributor
Contributor

Hi Li,

 

Thank you for the feedback. I tried it and it appears everything is working as expected.

 

Thank,

Dan

0 Likes