Dashboard_avatar
Feb 01, 2012
Post id: 309561 Report Item

I am apprently having a basic failure to 'get it'.  As a simplified version of the issue I am seeing, I created a command that reads a node's transform translation and adds one to the X component.  The issue is that the object does not redraw until I force it via mousing over something like the viewcube.  Any clue why this is occuring?






MStatus stat; 
MSpace::Space spc = MSpace::kWorld;
MFnTransform transFn;
stat=transFn.setObject(gCursorDagPath);
MVector mv=transFn.getTranslation(spc,&stat);
MPoint position(mv);
position.x+=1;
MVector mv2(position);
transFn.setTranslation(mv2,spc);




 


Dashboard_avatar
Feb 03, 2012
Post id: 309569 Report Item

Maya uses a "Push-Pull Model". which is a quite important concept when you do Maya programming.

When you set an attribute for a node, Maya only marks all the connected nodes after the node you just modified as "dirty". All the "value update" things should happen once you request an output value of a particular node, which will cause a chain of upates.

In your case, even though you set translation of a node, Maya just mark all the attributes which would be affected by your changes as dirty. It won't do the chain of updates ( "redraw" in your case) until it "needs to". The reason why it only redraw when you mouse over viewcube is because Maya needs to redraw the viewport when you mouse over viewcube (see the viewcube is highlighted ?), which will cause everything within viewport, including your object, be updated.

Hope it helps!
Cheers! :)

Dashboard_avatar
Feb 03, 2012
Post id: 309575 Report Item

Thanks for the reply.  I figured that might be it, so I force a viewport update.  However, that also did not redraw.  Apparently the object has to be selected.  That was not obvious from the documentation, but would make sense if all plugin functionality must follow a "user centric" workflow.  I am unfortunetly not a maya guru in anyway.