forked from CADacombs/rhinopython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xLayer.py
37 lines (26 loc) · 1007 Bytes
/
xLayer.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
31
32
33
34
35
36
37
"""
160528: Created.
160618:
"""
import rhinoscriptsyntax as rs
import scriptcontext as sc
import System
def areLayerAndAllAncestorsVisible(idx_rdLayer_Child):
rdLayer_Child = sc.doc.Layers[idx_rdLayer_Child]
if not rdLayer_Child.IsVisible: return False
idLayer_Parent = rdLayer_Child.ParentLayerId
if idLayer_Parent == System.Guid.Empty: return True
else:
idx_rdLayer_Parent = sc.doc.Layers.Find(idLayer_Parent, True)
return areLayerAndAllAncestorsVisible(idx_rdLayer_Parent)
def getLayerIdsFromNames(sLayerNames):
"""
Parameter: List of layer names
Returns: List of layer GUID's
"""
# Get all layer GUID's in document.
idx_Layers = rs.LayerIds()
if idx_Layers is None: return
idx_Layers_Target = [idx_Layer for idx_Layer in idx_Layers if rs.LayerName(idx_Layer) in sLayerNames]
return idx_Layers_Target
if __name__ == "__main__": print getLayerIdsFromNames(["Default"])