I want to access from a toolbar URCap to the instances of an URCap program node I have inserted in the current program, for example to show a value stored in the model of that node. How can I do this? I have found some relevant threads but I can’t find a solution:
the simplest way to achieve this is using a singleton class that stores the Program Node References e.g. in an ArrayList on runtime. Add your references to the singleton instance when calling the createNode method of your ProgramNodeService. This will also be called when loading programs. After that, call your singleton instance from your toolbar and get your program node references.
Thanks a lot!
However I can’t understand how to remove from the ArrayList the references of the program nodes which are deleted in PolyScope or the ones of the previous program when I open a new one.
the references to the program nodes that were deleted will stay alive in polyscope until they lose their undo/redo scope. Therefore you shouldn’t delete them in the arraylist
Ok, so if I want the toolbar to show only some information about the program nodes in the current program I should restart the teach pendant and load only the program I’m interested in, without loading, before it, other programs containing instances of that node. Am I correct?
yes you are. In this case, i would check which references (in your program nodes e.g. rootTreeNode) only exist on Program Tree Scope. The Creation Context would help a bit but not really solve this.