-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathextractObjectsBottomFace.py
More file actions
63 lines (52 loc) · 1.62 KB
/
extractObjectsBottomFace.py
File metadata and controls
63 lines (52 loc) · 1.62 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""Returns the bottom faces of selected solids, and prints the sum area of the output faces. """
import rhinoscriptsyntax as rs
import trkRhinoPy as trp
# !-RunPythonScript "objectsBottomFace.py"
def inputFunc():
"""returns the selection
Returns:
ids: ids of selection
"""
objs = rs.GetObjects("Select polysurface to explode", rs.filter.polysurface, preselect=True)
return objs
# def calcArea(srfs):
# areas = []
# for srf in srfs:
# areas.append(rs.SurfaceArea(srf)[0])
# totalArea = sum(areas)
# totalAreaPy = totalArea/3.3058
# print totalArea, totalAreaPy
# # txt = rs.ClipboardText(totalArea)
def outputFunc(objs):
"""Extracts the bottom faces of each solid in selection
Args:
objs (list of ids): list of ids
Returns:
list: list of bottom faces
"""
rs.EnableRedraw(False)
bottomFaces = []
for obj in objs:
resultFaces = trp.getBottomFace(obj)
# print resultFaces
for resultFace in resultFaces:
trp.copySourceLayer(resultFace, obj)
try:
trp.copySourceData(resultFace, obj)
except:
pass
bottomFaces.append(resultFace)
rs.SelectObjects(bottomFaces)
group = rs.AddGroup()
rs.AddObjectsToGroup(bottomFaces, group)
rs.EnableRedraw(True)
return bottomFaces
def returnFaces():
"""runs the selection, extraction, and print calculation functions
"""
objs = inputFunc()
rs.UnselectAllObjects()
outputsrfs = outputFunc(objs)
print trp.calcAreas(outputsrfs)
if __name__ == '__main__':
returnFaces()