Can volume reply in gallons instead of cubic inches?

Rhino 7
I’m working with a 60 gallon air tank and would really like to see the Volume command show gallons, or quarts.
Is there a way?

or make my own command??
Is there a way to copy the code for the Rhino volume command and mod the code to give other units? (Liter, quart, gallon, etc.)

Thanks!

Hi,

Rhino’s Volume command reports the result in the current model units, as cubic units. So if your file is in inches, the result will be in cubic inches; if it is in feet, it will be in cubic feet, and so on.

As far as I know, there isn’t a built-in setting to make the native Volume command display gallons, quarts, liters, etc. directly.

You also can’t copy and modify the internal Rhino Volume command itself, since that is part of Rhino’s compiled code.

But you can definitely make your own small script or custom command that gets the volume from the selected object and then converts it to whatever units you need.

For example, for a 60 US gallon tank:
60 US gallons = 13,860 cubic inches
60 US gallons = 240 US quarts
60 US gallons ≈ 227.125 liters

So the usual workflow would be either:
Run Volume → get cubic inches/feet/etc. → convert the result

or create a simple RhinoPython command that does the conversion automatically.

One thing to watch out for is whether you mean US gallons or Imperial gallons, since they are different.

Thank you.

I’ve been doing the workflow you suggested, but thought it would be nice to have some code to do it. I found this on the Github site:

VolumeLiters.py (706 Bytes)

It does liters, and looks like line 21 has some function calls that I’d need to figure out! I started coding when the Dead Sea was ill (1960’s)

Hi,

Nice find. That script is already doing most of the work. Line 21 is just converting Rhino’s cubic model units into liters. I made a small version below that also reports US gallons and quarts.

import rhinoscriptsyntax as rs


def VolumeFluidUnits():
    """Report volume in liters, US gallons, and US quarts."""

    objects = rs.SelectedObjects()
    if not objects:
        objects = rs.GetObjects("Select closed surfaces, polysurfaces, or meshes")
        if not objects:
            return

    volume = 0.0

    for obj in objects:
        if rs.IsMesh(obj):
            result = rs.MeshVolume(obj)
            if result:
                volume += result[1]

        elif rs.IsObjectSolid(obj):
            result = rs.SurfaceVolume(obj)
            if result:
                volume += result[0]

    if volume == 0.0:
        print "No closed volume found."
        return

    # 1 liter = 10cm x 10cm x 10cm
    liters = volume / (rs.UnitScale(rs.UnitSystem(), 3) * 10.0) ** 3

    us_gallons = liters / 3.785411784
    us_quarts = us_gallons * 4.0

    print "Volume = {:.3f} liters".format(liters)
    print "Volume = {:.3f} US gallons".format(us_gallons)
    print "Volume = {:.3f} US quarts".format(us_quarts)


if __name__ == "__main__":
    VolumeFluidUnits()

This uses US gallons. Imperial gallons would need a different conversion factor.

That is awesome!

I’ll try it out next I’m on the drawing.

Thanks a lot!

FWIW, liters and cubic decimeters were added to the volume units in Rhino 8.
-wim

Works the bomb!