How to switch process in isDefined() method of custom URCap?


I have a question about isDefined() method in the custom URCap node.

I have found this method is called at the following times.

  1. Open the program file that has custom URCap node
  2. Exit the program screen
  3. Move the scroll bar in program screen
  4. Execute the program that has custom URCap node
  5. Select the custom URCap node
  6. Change the setting of custom URCap node

For that reason, when I build the program that has many URCap node and execute it, isDefined() is called for the number of nodes.
And this has caused the robot to take long time to start moving.

I used this method to determine if other nodes are in the right place, but there is no reason to explore child nodes when executing.

Is there any way to switch process in isDefined() between when editing program and when executing program ?

Per the manual:

In order for the method to function correctly on a Parent node, it has to check all the children nodes, as if any of them are undefined, so is the parent. So no, I don’t think there’s any way to alter this behavior.

Hi Eric
Thank you for the reply.

I know it is inevitable that the function is called when I start the program.
I would like to implement as below in order to do something only when I editing program, not on executing if it is possible.

public boolean isDefined() {
   if ( // detect whether if the user editng the program ) {
        // ...

Does anyone have a good idea to judge whether if the user is editing the program, or executing the program ?
Thank you.

I mean, the generateScript() method runs when the program is run, but also when the user saves the program. Dunno if you can leverage that or not