Universal Robots Forum

How to delete a specific urcap node

Hello! I can’t figure out how to delete a specific urcap node using the button on this node

I’m trying to make an analog of a button from a standard waypoint tab


Take a peek at the TreeNode data type. Each node can be accessed as a TreeNode, which has a removeChild() method. I can’t say I’ve seen that button you’re referring to. I have only worked with the e-series, so maybe that’s a CB? I’m not sure what it’s functionality is. If you can delete the node from itself, you will likely have to do a fair bit of additional work, as you will need to create a custom interface so you can access different contributions from within others in order to call something like “parent.removeChild(activeTreeNode).”

Essentially you call a function from a different contribution (in this case it would be the Move node) and pass it a TreeNode from the active contribution (the waypoint node) in order to delete itself. It is, unfortunately, not as trivial as you would think.

Hi! Thanks for the answer! In the course of work, I came across the fact that the getChildren() function gives a different result every time it is called) Perhaps you know why this can happen?

Yeah, dealing with the TreeNode structure is pretty strange. Lets pretend the node you’re calling getChildren() on is called “root.” Basically, any time you’re dealing with root, put this line first:

root = programModel.getRootTreeNode(exampleContribution.this);

Then do something like root.getChildren(). For some reason the exact reference changes, but calling this every time before using it seemed to fix it for me. It’s a solution I’d found posted somewhere else here on the forum as well.

Likewise, the exact ID of the children might change too, if I remember correctly. For this you might have to get creative about how you identify each child. You could use their indexed position of the array returned from getChildren(), or add a custom type of something like NodeType and check for this if you’re populating the tree with custom UR Cap nodes. Not knowing your exact use case, I can’t get much more specific than that.