Universal Robots Forum

List of variables

how do I create a drop down list containing all variables specified in the program?

1 Like

Hi @veltrubsky,

This is currently not supported in the API.
But why not create a feature request for this possibility?

(Valid for PolyScope, SDK

And I pent so much time looking for it :frowning:

Using the API, you can access the Features set up under Installation.
Thus you are able to read the feature points, lines and planes, both their type and positions.

(Valid for PolyScope, SDK

In the program node contribution , if I want to have access to the variables i use something like:

Collection allVariables = apiProvider.getProgramAPI().getVariableModel().getAll();
However I 'm not getting the planes and lines, I do understand that they are in the installation side, and that they are features…But how can I access them from the contribution side?

Sorry for the dummy question, I just saw:
Collection allFeatures = programAPI.getFeatureModel().getGeomFeatures();

While in the editing of a node, can I read the values feature points, line and planes? With the following command:

Collection allFeatures = programAPI.getFeatureModel().getGeomFeatures();

I can get their names but not values. Whenever I try to read them, from model i always get default value:

System.out.println("Lets get a point: " + model.get(“Point_1”, DEFAULT_POINT).getPose());

I would like to use it in my program before the user runs the program!

I am not sure what you are fetching from the “model” object, but assuming that is the DataModel, if you have not used model.set(<key>, <feature>) it will just return the default value.

If you iterate over your Collection<Feature> allFeatures object, you can try reading getPose() for each Feature in your iterator to see the output.

The model is the DataModel indeed.
I read in another post that the Installation Vars and the Features values are only available after program starts. In fact I only understood it when I opened the script generated by a default program. There you can see that these variables and features are put in the top of the program with their respective values.
It’s a pitty we can’t access the value from configuration node, because sometimes, like in my case, I would like to know the value of a plane that I use as a reference plane, to check for reach limits while the user is configuring the variables.

The code I used to try to capture the values from the Installation variables and Features is bellow. Like stated, we can only access their names.

public VarsTestProgramNodeContribution(VarsTestProgramNodeView view, DataModel model, ProgramAPIProvider apiProvider, CreationContext context) {
this.programAPI = apiProvider.getProgramAPI();
this.undoRedoManager = apiProvider.getProgramAPI().getUndoRedoManager();
this.keyboardFactory = apiProvider.getUserInterfaceAPI().getUserInteraction().getKeyboardInputFactory();
this.model = model;



public void loadVars()
Collection allVariables = programAPI.getVariableModel().getAll();
Collection allFeatures = programAPI.getFeatureModel().getGeomFeatures();
System.out.println("List of Features: ");
for(Feature f: allFeatures)

  Feature s = programAPI.getFeatureModel().getBaseFeature();
  System.out.println("Lets get a point: " + model.get("Point_1", s).getPose());
  System.out.println("\r\nList all vars:" + allVariables.size());
  for(Variable v: allVariables)
  	System.out.println(v.getDisplayName() + " " + v) ;
  	System.out.println("Get ivar: " + model.get("i_var_1",0));