# World Position In An Expression

**URL:** https://forum.highend3d.com/t/world-position-in-an-expression/2268
**Category:** Maya
**Tags:** mel
**Created:** [April 21, 2007, 2:25am UTC](https://forum.highend3d.com/t/world-position-in-an-expression/2268 "2007-04-21T02:25:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![combustible](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/c/71c47a/32.png) [@combustible](https://forum.highend3d.com/u/combustible)
#### Post date: [April 21, 2007, 2:25am UTC](https://forum.highend3d.com/t/world-position-in-an-expression/2268/1 "2007-04-21T02:25:12Z")

</div>

I hope this isn't a dumb question, but how do you query the world position of an object in an expression?

---

<div class="post-metadata">

### Author: ![kurianos3d](https://forum.highend3d.com/user_avatar/forum.highend3d.com/kurianos3d/32/55947_2.png) [@kurianos3d](https://forum.highend3d.com/u/kurianos3d)
#### Post date: [April 21, 2007, 7:49am UTC](https://forum.highend3d.com/t/world-position-in-an-expression/2268/2 "2007-04-21T07:49:43Z")

</div>

CODE  
float $get\_xfrm[]=`xform -q -ws -t p1`;  
print $get\_xfrm;  
print "\n";

-t means translation try this  
p1 means ploySphere

---

<div class="post-metadata">

### Author: ![joojaa](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/j/5daacb/32.png) [@joojaa](https://forum.highend3d.com/u/joojaa)
#### Post date: [April 21, 2007, 9:15am UTC](https://forum.highend3d.com/t/world-position-in-an-expression/2268/3 "2007-04-21T09:15:40Z")

</div>

Well its not necessarily very smart to use xform or any other mel for that matter in a expression. Because then you have no trigger.

Anyway bear in mind that expressions have nothing to do with mel per see, they do however parse mel but that dont work very well for the expression engine because they aren't part of the DG.

---

<div class="post-metadata">

### Author: ![ewerybody](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/e/bcef8e/32.png) [@ewerybody](https://forum.highend3d.com/u/ewerybody)
#### Post date: [April 23, 2007, 7:53am UTC](https://forum.highend3d.com/t/world-position-in-an-expression/2268/4 "2007-04-23T07:53:09Z")

</div>

k. so what would you suggest?  
attach a constrained locator or something to geht the ws-pos from?

---

<div class="post-metadata">

### Author: ![joojaa](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/j/5daacb/32.png) [@joojaa](https://forum.highend3d.com/u/joojaa)
#### Post date: [April 23, 2007, 8:04am UTC](https://forum.highend3d.com/t/world-position-in-an-expression/2268/5 "2007-04-23T08:04:29Z")

</div>

well it depends on what you do. BUt yes thats a very viable option. But thing is it can possible solve it without expressions. It depends on whay your up to however.

---

<div class="post-metadata">

### Author: ![combustible](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/c/71c47a/32.png) [@combustible](https://forum.highend3d.com/u/combustible)
#### Post date: [April 28, 2007, 4:48am UTC](https://forum.highend3d.com/t/world-position-in-an-expression/2268/6 "2007-04-28T04:48:44Z")

</div>

Well I was trying to change the override color of a controller when a part of my skeleton moved past a certain point from another part.

I could use distancebetween or query the position of constrained locators but those methods were giving me trouble for some reason. Although there were no other connections to these locators, it was propagating transformations that it shouldn't have been.

I was just wondering if there was another method to do something like this.
