Universal Robots Forum

How to call an URCap with an URCap

Hello everyone,

Is it possible to call an URCap out of an URCap?

The purpose is to make a button in an URCap and when you press it, it will open another URCap in the tree of PolyScope.

Is this possible or something for Feature requests?
The program runs PolyScope 3.5.0.10584.

With regards,
D Voortman

1 Like

i’m not sure about this on version 3.5.0.10584 but for 3.5.4+ it works by using the ProgramNodeFactory:

rootTreeNode.addChild(programNodeFactory.createURCapProgramNode(YourURCapProgramNodeService.class));

1 Like

Hi,

I am also writing an URCap that will add third-party URCaps to the program tree.
However, I encountered the problem that I somehow cannot even add sample URCaps from the starter kit.
I was trying to to add the Ellipse Swing URCap to the tree to see if it works with the command:

ellipseTreeNode = rootTreeNode.addChild(programNodeFactory.createURCapProgramNode(EllipseProgramNodeService.class));

I can even create the .urcap file but when trying to install it on the PolyScope it only shows an exclamation mark in the setup next to the URCap without any further information. The Ellipse Swing sample URCap from the Getting Started kit is readily installed on the PolyScope.

Can you help me fix this? Do I have to add some further reference of the URCap that I want to include in my own URCap or something?

Many thanks in advance,
MPonya

you need to include the Ellipse ProgramNodeService and ProgramNodeContribution Classes inside your URCap Package and call them in the Activator class

Thank you for the advice! It helped a lot.

One further question is what to do in the case of third-party URCaps where I do not have the whole project but only the .urcap file which contains .class files. This means that I cannot simply include the .java classes to my URCap as I do not have them in that form.
Is it possible to insert a third-party URCap into the program tree from the .urcap file somehow?

Best,
MPonya

I’m not sure if you can just copy-paste them in the .urcap file but it should work by using a java decompiler. (at this point i’m no longer responsible for any copyright violation :slight_smile: )

I might just try the copy-paste first and see if it works. As you mentioned the decomplier might violate some licence rules.
Thank you for the answer.