Rhinoscript: calculate weight

rhinoscript

(Chanh Nguyen) #1

How to get results of the 2 decimal number in this script. Thanks for any help from everyone.

Option Explicit

Sub A()
** Dim obj, arrobj **
** Dim vol **
** Dim t**


** arrobj = Rhino.GetObjects(“Chon doi tuong”)**


** For Each obj In arrobj**


** t = Rhino.Surfacevolume(obj)**


** vol = vol + t(0)**


** Next**


** Rhino.Print “Please wait calculating volume…”**

** Rhino.Messagebox " Total Weight(g): " & Int(CStr(vol)) /64.9 , 0, “TOTAL WEIGHT” **
**End Sub **
Rhino.AddStartupScript Rhino.LastLoadedScriptFile
Rhino.AddAlias “aw”, "_NoEcho _-RunScript (A)"


#2

You can use Round function.
For 2 decimals, use:
vol=Round(vol,2)

second parameter is the decimals


(Chanh Nguyen) #3

Thank @Jarek very much!!!