0

What's the right way to disconnect/connect plugs during MPxNode compute() method?

I have a modified plugin that it's plugs are already connected to some other objects transform nodes, it always gives me the internal failure error when I want to update its plugs connection during the compute() method. Both MDGModifier connect and disconnect fails. Why do I keep getting this error?

If this is not possible, is there a way I can update the connections before compute() kicks in? I've tried doing so in setDepenedentsDirty() but the dirtied plugs still hold the old value during that method. Dirtied plug still has the old value during setDependentsDirty()

Any thoughts?

Community
  • 1
  • 1
Yasin
  • 609
  • 1
  • 10
  • 22
  • Why are you trying to change the connections during `compute()`? In theory, at least, they connections are static invariants for the node -- they are like the inputs and outputs of a function, and changing them on `compute()` is going to mess up the DAG graph by changing its topology and execution order. – theodox Aug 06 '16 at 05:17
  • Correct. Any suggestion where it's suited to change plugs connection outside `compute()` when one of the plugs are dirtied? – Yasin Aug 06 '16 at 09:16
  • 2
    I think I'd add a separate MPXCommand to do the entire operation and keep the graph intact, or if you needed to manage the flow split that part out into a switch node of some kind separate from the compute functionality. – theodox Aug 06 '16 at 21:31
  • That's interesting. How do you make two MPXCommands work together in this scenario? – Yasin Aug 06 '16 at 21:46
  • 1
    It'd have to be a user-initiated tool or a handler for an MSceneMessage. Again, you really don't want to be dynamically changing the graph, it will be nasty for perf – theodox Aug 09 '16 at 22:16

0 Answers0