RoboDK Forum
How to get a target's parent reference frame?- Printable Version

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API)
+--- Thread: How to get a target's parent reference frame? (/ Thread-How-to-get-a-target-s-parent-reference-frame)



How to get a target's parent reference frame?-Maarten-12-07-2022

How do I get a target's parent reference frame item? Meaning its direct parent frame, that is shown in the GUI by default under "Target position with respect to:"of the target properties window.

I tried
Code:
target.Parent()
at first, but that fails if a target is in a folder.

A way that seems to work is:
Code:
frame = robolinkutils.getAncestors(target,robolink.ITEM_TYPE_FRAME)[0]
which gets the first of all subsequent reference frames for a target.

Is there a cleaner way to get the frame item?

Kind regards,

Maarten


RE: How to get a target's parent reference frame?-Albert-12-07-2022

There is no cleaner way.

To make sure your script doesn't break you should make sure you at least have one ancestor in the list, so you can index the first item (index 0).

On the other hand, I recommend you to place coordinate systems inside folders and not the other way around.