Universal Robots Forum

How to cancel a node to insert

Hello.

I am having a problem with URCap development.

I would like to create a program where a user adds a child node under a parent node, and if it is not of a certain type, the insertion is cancelled.
Alternatively, I would like to know how a child node can get the type of its parent node.

Both the parent node and the child node are custom URCaps that I created.

Thank you for reading.

Yoshida

Unfortunately, no methods such as “getParent()” or similar are provided. Likewise, nothing exists such as an “onInserted()” method. The only way I’ve found to achieve something like what you’re looking for is to have the child nodes inserted programmatically from buttons on the Parent’s screen (as opposed to inserting them from the Polyscope UI on the left). This allows you to pass a reference to yourself (ie the parent) into the child.

As for rejecting the insertion, I had attended an ActiNav training, and even UR’s official program for that was incapable of this behavior. The best they had was when you press Play, it would THEN tell you that something was wrong. I imagine they were leveraging the generateScript() method for the structure checking, since they don’t have an onInserted() method.

Overall, the tree structure support is the most lacking aspect of the API in my opinion.

Hi, Eric.

Thank you for answer.

Your advice is very unfortunate news for me, but you have given me the opportunity to create another method.

My idea is to use “isDefined()” in the Contribution to monitor all child nodes and return false if there is another node. (Adding or deleting a node in “isDefined()” will throw an exception.)
This way, any user can’ t play at least.

If you have any advice, please let me know.

I hope this idea will help you too.

Yoshida