-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetSteelWeight.py
More file actions
41 lines (32 loc) · 1.84 KB
/
GetSteelWeight.py
File metadata and controls
41 lines (32 loc) · 1.84 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
#---------------------------------------------------------------------------------------------#
# Copyright Manuel Gomez (2019) #
# #
# This script calculates volume and translates to weight for steel density (0.284 lbs/in3) #
# #
#---------------------------------------------------------------------------------------------#
# Create button in Rhino and add this command: #
# ! _-RunPythonScript "GetSteelWeight.py" #
#---------------------------------------------------------------------------------------------#
# Version 1.0 (2019-01-20) #
# - Initial rev. #
#---------------------------------------------------------------------------------------------#
import rhinoscriptsyntax as rs
if rs.UnitSystem() != 8:
print("Units should be set to inches.")
exit()
object_ids = []
object_ids = rs.SelectedObjects()
while not object_ids:
object_ids = rs.GetObjects("Select some closed surfaces or polysurfaces",8+16)
#loop between objects
totalVolume = 0.0
for object_id in object_ids:
#check to see if the object is closed before calculating volume
if rs.IsObjectSolid(object_id):
blockVolume=rs.SurfaceVolume(object_id)
totalVolume = totalVolume + blockVolume[0]
else:
print "Object is not closed"
totalWeight = totalVolume * 0.284
print "The volume is " + "%.2f" % totalVolume + "sq.in"
print "The weight is " + "%.2f" % totalWeight + "lbs"