Universal Robots Forum

How do I implement a node like IF-ELSE?

I know that the parent nodes can access the child nodes using the CustomAPI.
But, the child nodes cannot get or modify parents or siblings.

However, in IF-ELSE node, an Else node which is a sibling node can be added or deleted through the button in If node.

When I created the If node in the constructor of the parent node, I used the CustomAPI to pass the Root TreeNode & DataModel of the parent node to the If node. (the DataModel was passed to use undo)
When the button of the If node is clicked, I added or removed the child node using the parent root TreeNode that was passed when the node was created.

This code seemed to work well for adding or removing sibling nodes.
However, if I save the program as .urp file and reopen it, Null point exceptions will occur.
The child node (If node) that is created when opening a .urp file does not seemed to be created in the parent node’s constructor.

How do I implement a node like IF-ELSE?

I want to create a parent node that has an If node as its child node when it is created.

2 Likes