+ Reply to Thread
Results 1 to 2 of 2

Thread: Find weight of metal content

  1. #1
    New Member aubergine2001's Avatar
    Join Date
    Nov 2010
    Location
    Halifax, Nova Scotia, Canada
    Posts
    19

    Find weight of metal content

    I am trying to write a script that;
    finds volume of object.
    then takes that volume that is in model units. (cubic millimetres for me)
    converts cubic millimetres to cubic centimetres
    takes cubic centimetres and multiplies by specific gravity of metal (925 silver most of the time). Though maybe a pull-down to choose if I need gold or other jewellery metals.
    Then print out the weight.

    I have started a basic script, but I get an error "can't multiply sequence by non-int of type 'float'".

    Any suggestions,

    Thanks in advance,
    Randy
    Attached Files

  2. #2
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,463
    Blog Entries
    19
    Hi Randy,
    SurfaceVolume returns two numbers (volume and error bound). Here's what I would do to adjust your script
    Python Code:
      """Rhino script for finding weight of object"""
      import rhinoscriptsyntax as rs
       
      def GetWeight():
          obj=rs.GetObjects("Select Objects for volume")
          massprop = rs.SurfaceVolume(obj)
          if not massprop: return
          volume, error = massprop
          centimeters = volume * 100
          weight = centimeters * 10.3
          print "The polysurface weight for 925 is:", weight
       
      GetWeight()

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts