Get numbers of TreeNode (or ProgramNode) in Robot Program

Hello,
I’m working on an URCap and I would like to know if it’s possible to get the number of nodes in the Robot Program. I find the API function
getRootTreeNode(this).getChilden()
but I cannot find a way to use it at the Robot Program level.

Alternatively, there’s a way to constraint the Robot Program to have a single node (that will be a instance of my URCap)?

Thank you in advance

Hi Silvia,

I’m working on an URCap and I would like to know if it’s possible to get the number of nodes in the Robot Program. I find the API function
getRootTreeNode(this).getChilden()
but I cannot find a way to use it at the Robot Program level.

Yes, this is because a program node’s scope of view is only within its own node. It was not designed to have “global” access to the entire program tree, only the children under it.

Alternatively, there’s a way to constraint the Robot Program to have a single node (that will be a instance of my URCap)?

As far as I know, there isn’t a built-in set of methods in the SDK that allows you to do this. What are you trying to achieve having a single node instance in the Robot Program?

Thank you for your reply.

The URCap should be the only know added by the user because the robot script I would like to create and execute is the one created in the generateScript of this URCap.

Could you maybe move the script code into the installation node’s generateScript method? That way you can guarantee there’s only one instance of your script code running.

I already implemented an installation node to do other operations so I cannot implement the solution you suggest.