Get position of component within group

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

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:


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?

Add the location of the group. :slight_smile:

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.

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

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

print, ':', group.getLocation()

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

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):

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

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

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