# Get position of component within group

**URL:** <https://forum.inductiveautomation.com/t/get-position-of-component-within-group/20085>\
**Category:** Ignition\
**Tags:** python, scripting\
**Created:** [October 11, 2018, 1:27pm UTC](https://forum.inductiveautomation.com/t/get-position-of-component-within-group/20085 "2018-10-11T13:27:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevstewart21](https://avatars.discourse-cdn.com/v4/letter/k/b3f665/32.png) [@kevstewart21](https://forum.inductiveautomation.com/u/kevstewart21)\
**Post date:** [October 11, 2018, 1:27pm UTC](https://forum.inductiveautomation.com/t/get-position-of-component-within-group/20085/1 "2018-10-11T13:27:51Z")

</div>

I’m trying to use a script to get the positions of components within a group, but if I run:

```auto
window.getRootContainer().getComponent("Group 1").getComponent("MyComponent").getLocation()

```

It tells me that its at (0,0), regardless of where the component is. Running the same code on a component that isn’t in a group:

```auto
window.getRootContainer().getComponent("MyOtherComponent").getLocation()

```

yields the correct set of coordinates. Is there a different way to go about getting coordinates of grouped components, or am I just missing something in the script I currently have?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 11, 2018, 1:48pm UTC](https://forum.inductiveautomation.com/t/get-position-of-component-within-group/20085/2 "2018-10-11T13:48:49Z")

</div>

Add the location of the group. 🙂

---

<div class="post-metadata">

**Author:** ![kevstewart21](https://avatars.discourse-cdn.com/v4/letter/k/b3f665/32.png) [@kevstewart21](https://forum.inductiveautomation.com/u/kevstewart21)\
**Post date:** [October 11, 2018, 2:07pm UTC](https://forum.inductiveautomation.com/t/get-position-of-component-within-group/20085/3 "2018-10-11T14:07:10Z")

</div>

I see what you’re saying as far as getting the absolute position in the end, but currently I can’t get a relative position of my grouped component. Every call to getLocation() for components in the group returns (0,0), no matter where they are.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 11, 2018, 2:35pm UTC](https://forum.inductiveautomation.com/t/get-position-of-component-within-group/20085/4 "2018-10-11T14:35:57Z")

</div>

So far, I’m not able to replicate this.

```python
window = system.gui.getParentWindow(event)
group = window.getRootContainer().getComponent("Group")

print group.name, ':', group.getLocation()

for component in group.components:
  print component.name,':', component.getLocation()

```

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/b/b3313867a4d2c95e94d974b7232ea27c1b2b59ba.jpg)

---

<div class="post-metadata">

**Author:** ![kevstewart21](https://avatars.discourse-cdn.com/v4/letter/k/b3f665/32.png) [@kevstewart21](https://forum.inductiveautomation.com/u/kevstewart21)\
**Post date:** [October 11, 2018, 2:57pm UTC](https://forum.inductiveautomation.com/t/get-position-of-component-within-group/20085/5 "2018-10-11T14:57:04Z")

</div>

Ok, I just tried the same code that you used with some new buttons as well as one of the components that I want the location of, here are the results (MyComopnent is the green arc):  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/275428f0f9be7b3c6f370596ab16022cae24551a.PNG)  
Could it be that there is something about these components that prevent getting the location? This is part of a project that I’ve inherited so I don’t know if anything special was done when these were created

---

<div class="post-metadata">

**Author:** ![sistemas](https://avatars.discourse-cdn.com/v4/letter/s/858c86/32.png) [@sistemas](https://forum.inductiveautomation.com/u/sistemas)\
**Post date:** [February 5, 2019, 12:56pm UTC](https://forum.inductiveautomation.com/t/get-position-of-component-within-group/20085/6 "2019-02-05T12:56:14Z")

</div>

Hi kev, did you try the system.gui.transform()?

---

<div class="post-metadata">

**Author:** ![vec](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/vec/32/30636_2.png) [@vec](https://forum.inductiveautomation.com/u/vec)\
**Post date:** [May 21, 2020, 2:59pm UTC](https://forum.inductiveautomation.com/t/get-position-of-component-within-group/20085/7 "2020-05-21T14:59:37Z")

</div>

For what it is worth,  
if you try iterating through .getComponents() on the root container it will return “PathBasedVisionShape(MyComponent)”

If you use .getBoundingRect() on the component it returns .x,.y,.w & .h  
See this post on PathBasedVisionShape mouse click  
[PathBasedVisionShape](http://forum.inductiveautomation.com/t/is-there-a-way-to-allow-mouse-clicks-to-pass-to-object-beneath/17093/2)
