# Manipulating Planes in script

**URL:** <https://forum.universal-robots.com/t/manipulating-planes-in-script/19087>\
**Category:** Technical Questions\
**Created:** [February 7, 2022, 11:02am UTC](https://forum.universal-robots.com/t/manipulating-planes-in-script/19087 "2022-02-07T11:02:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![m.hammerton](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@m.hammerton](https://forum.universal-robots.com/u/m.hammerton)\
**Post date:** [February 7, 2022, 11:02am UTC](https://forum.universal-robots.com/t/manipulating-planes-in-script/19087/1 "2022-02-07T11:02:47Z")

</div>

I have a Plane setup, Tray\_1  
I can adjust values eg Tray\_1 = Tray\_1[2] + value,  
this works as expected.

so when I want to set it back to its original values  
I would have thought  
Tray\_1 = Tray\_1\_const  
would work

But No!

Can anyone explain why?

If I use it as an assignment in the program it works so why not in a script file?

---

<div class="post-metadata">

**Author:** ![anon63330883](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@anon63330883](https://forum.universal-robots.com/u/anon63330883)\
**Post date:** [February 7, 2022, 2:43pm UTC](https://forum.universal-robots.com/t/manipulating-planes-in-script/19087/2 "2022-02-07T14:43:43Z")

</div>

Your plane, Tray\_1, is a pose variable. I am not sure how you got the first part, Tray\_1 = Tray\_1[2] + value. Maybe the Assignment node creates a new variable of the same as your plane, but it is a float type. If Tray\_1 and Tray\_1\_const are both pose the code will work.

---

<div class="post-metadata">

**Author:** ![m.hammerton](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@m.hammerton](https://forum.universal-robots.com/u/m.hammerton)\
**Post date:** [February 7, 2022, 3:12pm UTC](https://forum.universal-robots.com/t/manipulating-planes-in-script/19087/3 "2022-02-07T15:12:43Z")

</div>

FYI I’m using a UR5e with 5.11 version software

Tray\_1 is a Plane created using the features menu in installation.  
Which is a and thus so can be modified, Hence Tray\_1 = Tray\_1[2] + value (value is an arbitrary No) which works as expected and adjusts the Z value of the plane.

as I understand it, when Tray\_1 is created the Robot also creates a Tray\_1\_const which has the exactly the same values as Tray\_1. However as its a constant it **cannot** be modified!

as indicated in my original post

Tray\_1 = Tray\_1\_const works fine when its used in the main body of the program in an assignment,

So my question is why doesn’t it work from a Script file?  
are values not accessible in a script file? (I find that hard to believe)

---

<div class="post-metadata">

**Author:** ![eric.feldmann](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@eric.feldmann](https://forum.universal-robots.com/u/eric.feldmann)\
**Post date:** [February 7, 2022, 3:47pm UTC](https://forum.universal-robots.com/t/manipulating-planes-in-script/19087/4 "2022-02-07T15:47:59Z")

</div>

From my experience, the Const version of the feature is not global. You can actually test this by manually typing Tray\_1\_const into your assignment node and watch it fail. For whatever reason, that const variable HAS to be selected from the dropdown menu. You therefore must pass the const version into your script via a function call and reassign your plane that way, if you want to do it all with script. I haven’t done it myself, but it might be interesting to see the script polyscope generates when you do the assignment node, since it works there for some reason.

---

<div class="post-metadata">

**Author:** ![anon32693620](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@anon32693620](https://forum.universal-robots.com/u/anon32693620)\
**Post date:** [February 7, 2022, 3:59pm UTC](https://forum.universal-robots.com/t/manipulating-planes-in-script/19087/5 "2022-02-07T15:59:46Z")

</div>

He means if you are changing Tray\_1 which is a Pose variable into a float variable with that Tray\_1 (Pose) = Tray\_1[2] (float) + value (assuming float). If you are trying to change just the z value it would be Tray\_1[2] = Tray\_1[2] + value. Also eric is right where you should choose the constant variable from the drop down box if you are using the Script node. If you are manually typing the script from your own URCap then you would need to pull the Pose data from the installation node. I believe the UR side doesn’t actually have a variable in the script made for the const but places the original pose there instead.

For Instance your variable Tray\_1 would show up in the Script as “Tray\_1” so if you did Tray\_1 = Tray\_1 that is exactly what you would see in the Script. If you do Tray\_1 = Tray\_1\_const though by selecting the const from the dropdown box, you would actually get Tray\_1 = p[some\_data] and not Tray\_1 = Tray\_1\_const. So when you type in Tray\_1\_const it does not know what variable you are referencing.

I have attached an image with an example showing this. On the left is the program when the first Plane\_1\_const I selected with the Drop down and the second one I physically typed in.

 ![Plane_const_error](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/e/e781be1d742381b08fa22c3fafb4aa79eb0e6621.png)

---

<div class="post-metadata">

**Author:** ![bba](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/bba/32/555_2.png) [@bba](https://forum.universal-robots.com/u/bba)\
**Post date:** [February 9, 2022, 6:31pm UTC](https://forum.universal-robots.com/t/manipulating-planes-in-script/19087/6 "2022-02-09T18:31:34Z")

</div>

The reason this does not work from a script file (or typing in the logical script commands) :  
Tray\_1 = Tray\_1\_const  
is because Tray\_1\_const does not really exist as a truly global variable. It ONLY exists in the mind of the Polyscope editor. When you select it from a dropdown in the expression editor of polyscope the polyscope editor will pull in the actual pose value for Tray\_1 (as taught in the Installation) and substitute this for the underlying script it generates.

---

<div class="post-metadata">

**Author:** ![mmi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/mmi/32/691_2.png) [@mmi](https://forum.universal-robots.com/u/mmi)\
**Post date:** [February 10, 2022, 11:32am UTC](https://forum.universal-robots.com/t/manipulating-planes-in-script/19087/7 "2022-02-10T11:32:53Z")

</div>

The workaround would be to assign Tray\_1\_const to global variable in polyscope “before start” section.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/f/f3908f04b9a5ed80cd1c97e153fbc8f2f5a7f35f.png)

---

<div class="post-metadata">

**Author:** ![m.hammerton](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@m.hammerton](https://forum.universal-robots.com/u/m.hammerton)\
**Post date:** [February 11, 2022, 7:23am UTC](https://forum.universal-robots.com/t/manipulating-planes-in-script/19087/8 "2022-02-11T07:23:37Z")

</div>

I did something similar  
I created a Variable Tray\_1\_Mstr and in the Before start  
Tray\_1\_Mstr := Tray\_1\_const

then in my Script file when I need to set it back to its original value

Tray\_1 = Tray\_1\_Mstr

Its a work around but it’ll have to do!

I just wanted to try and keep the amount of variables to a minimum to try and conserve memory.
