Detect error-causing nodes in XPresso
-
Hi,
I am trying to write a python script that detects error-occuring nodes in XPresso.
It seems that there is a method GvNodeMaster.Execute() for checking if the node master is including error node, and returns the type of error.
However, I tried with an xpresso network with a Math node that divides by zero and an unlinked Obejct node and did not get the expected results.
Code:import c4d def main() -> None: xpresso_tag = op.GetTag(c4d.Texpresso) master = xpresso_tag.GetNodeMaster() print(master.Execute()) if __name__ == '__main__': main()
Result:
0
I was expecting
c4d.GV_CALC_ERR_DIVISION_BY_ZERO
which is 10 orc4d.GV_CALC_ERR_UNDEFINED
which is 2.
Am I doing something wrong? Any help would be appreciated. -
Hi @kng_ito,
Please excuse the delay. You posting is not forgotten and will be processed asap. Unfortunately I'm currently under deadlines pressure and cannot provide fast support.
Cheers,
Ilia -
Hi @kng_ito ,
Please excuse the delayed answer.
According to our codebase the Execute() function will return GV_CALC_ERR_CALCULATION_FAILED for the calculation errors happening on master or global scope, namely when the GvNodeMaster was not able to calculate successfully (i.e. GvCalcState higher than GV_CALC_STATE_LOCAL_FAILURE). Issues like zero division only cause local failure, hence are not returned as error in Execute() function. Unfortunately, there's not much you can effectively do here.
In our SDK support meeting Ferdinand suggested an approach of adding intermediate xpresso python node, where you can detect and handle issues yourself. However, this highly depends on your use-case scenario, because if you for example need to batch-process xpresso graphs, this won't be any practical.
Cheers,
Ilia -
Hi @i_mazlov ,
Unfortunately, the python node approach is not effective for my use case, so I may have to emulate the error conditions on my own for each node.
In any case, thank you for your answer.