I have this script that retrieves the immediate parent of a selected object. It works well if I only have one selected but not on multiple selection.
For instance, if the hierarchy is as follows:
- objectA_grp
-
objectA_geo
-
objectB_grp
-
objectB_geo
-
objectC_grp
-
objectC_geo
Selects all the geo objects. I would expect only three result
objectC_grp
objectB_grp
objectA_grp
However, when I run the script, it returns redundant objects
objectC_grp
objectB_grp
objectA_grp
objectC_grp
objectB_grp
objectA_grp
objectC_grp
objectB_grp
objectA_grp
Is there a way around this? Thank you for looking at the problem
The script is as follows:
$sel= ls -sl
;
for ($list in $sel){
$parent = listRelatives -p
;
print $parent;
}