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

SubDObject Volume Calculation

$
0
0

Hello fellow rhino users,

I have the following python code to calculate volume of certain objects. I can get the volume of meshes, polysurfaces and surfaces but cannot get the volume of the subds. Does anyone know how to do it (without converting them into meshes of course)? (If you know how to display python code properly in the forum, could you please tell me how to do it?)

  def cumulativeVolume():
      obj = rs.GetObjects("Objects for weight calculation", 8+16+32+262144+1073741824, True, True)
      if not obj: return
      
      meshVol = []
      brepVol = []
      
      for object in obj:
          print "Object type: ", rs.ObjectType(object)
          
          if rs.ObjectType(object) == 32:
          
              Vmesh = rs.MeshVolume(object)[1]
              meshVol.append(Vmesh)
          
          # object is SubD
          elif rs.ObjectType(object) == 262144:
              Vmesh = rs.SurfaceVolume(object)[0]
              meshVol.append(Vmesh)
          else:
              i = rs.coercebrep(object)
              blockVolume = i.GetVolume()
              brepVol.append(blockVolume)
          
      Vmm3 = sum(meshVol) + sum(brepVol)
      return Vmm3
  
  V = cumulativeVolume() / 1000

9 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles