Universal Robots Forum

Help to do a URSim code

Hey!

I need some help to find how to make a script change a variable in the UR program.
I send an image from what I’m trying to do, if someone could help me with it

Is there a specific reason you are using a script node? You could just use an assignment Node to change the variable value.

If you are wanting to do it as a function; you can place the function you created in the before start sequence and then call that function in your main program. Which that script node would just be a line as “var()”.

This script will do more things, they will check some states and will result in a number in this variable (between 1 and 9).
I wanna read this number as a variable in my program, but for some reason, this script doesn’t change the variable to 1 (I put this script as an example just to force be 1), I’m studying about UR, so I don`t know many things about,
What do I need to do to call this function to change my variable?

You aren’t actually calling your function in this case. You have defined a script file containing a function defined as var(). In your main program you need to insert another script node that just says “var()” to actually call your function.

2 Likes