Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5850

Get volume of each object in a file using python

$
0
0

@Rebecca_Napolitano wrote:

Hi! I am trying to get the volume of each block in my file (they are extrusions/polysurfaces). I have the following code:
import rhinoscriptsyntax as rs

tolerance = 170 #m3


#pick an object
object_id = rs.GetObjects()

#Loop between my objects
for object_i in object_id:
#deselect any objects
rs.Command("-_selnone")
#get block id
#print object_i
object_i = str(object_i)
print type(object_i)
block = rs.Command("-_SelID " + object_i)
#get volume
blockVolume = rs.Command("-_Volume ")
blockVolume = str(blockVolume)
print "the volume is " + blockVolume
#print type(volume)
#delete if too small
if blockVolume < tolerance:
    rs.Command("-_Delete")
    print "Deleting block"

However the for loop does not work since blockVolume initially is a boolean. I changed it to a string just to print it out in a way that is easy for me to read.
How can I get rhino to return the volume in a way that is not a boolean? It prints to the console fine.
Thank you!!!

Posts: 4

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 5850

Latest Images

Trending Articles



Latest Images