I have am developing a URCap that has two different program nodes. One for writing and one for reading. I would like to make an assignment in the program tree so that the return value of theh read node is saved in a variable in PolyScope. Does anyone know how I could achieve that?
This is what my nodes look like:
So basically I would like to assign the return value of the read CNC on line 3 to var_1
Can anyone help me?
Ctrl+F for variable, and read up on the VariableFactory specifically. I think you can find what you’re looking for there.
Otherwise you can just write in your generateScript() method something like
"global myVar = RETURN_METHOD_OUTPUT_HERE"
And it should work for you
Would I be able to use that global var in the program tree? The end result I’m trying to achieve is something like this:
I want to use the assignment node to create multiple variables which store the values retrieved in the READ nodes. And then I want to display the retrieved values.
Would the example you gave allow for the automatic creation of multiple of these variables? Like the example here:
If possible I would like to allow the user to just press create new and then assign one of the READ nodes. My understanding of the global variable is that it works similar to saving something in the datamodel.
Yes you can create variables that show up in the dropdown menu. Just be sure to add it to the datamodel otherwise it won’t show up.
As you can see, var_5 is in the dropdown as a result of storing it in the datamodel
As another option, you can add your own custom functions to the “Script” node in Polyscope as follows:
Here I’ve added some commands to control the welder, and this allows them to be selectable from the dropdowns in Polyscope:
It separates them by package name, and you can have them take input parameters and return a value. So you COULD write one that takes as an input parameter, the address to the CNC, and returns whatever value. You could then use the built-in assignment node, and just select the “readFromCNC(address)” command.
Very clear answer! Thank you. I understand how it works now.