-
Notifications
You must be signed in to change notification settings - Fork 3
/
objectTopGroup.py
30 lines (26 loc) · 1.14 KB
/
objectTopGroup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#**********************************************************************************************#
#********* Return the top most group name of an object ****************************************#
#********* by Djordje Spasic ******************************************************************#
#********* [email protected] 6-May-2014 **************************************************#
"""
This small function replicates the "ObjectTopGroup" RhinoScript function, which still hasn't been implemented
into PythonScript.
Returns the top most group name that an object is assigned. This function primarily applies to objects that are
members of nested groups.
"""
import rhinoscriptsyntax as rs
import scriptcontext as sc
def objectTopGroup(_id):
groupNames = sc.doc.Groups.GroupNames(False)
groupName = False
for i in range(rs.GroupCount()):
groupRO = sc.doc.Groups.GroupMembers(i)
for ele in groupRO:
if ele.Id == _id:
groupName = groupNames[i]
if groupName:
print groupName
else:
print "The element you chose does not belong to any group"
id = rs.GetObject()
objectTopGroup(id)