Forgot password?

Create an account!

Forum

« back

RhinoScript – how to calculate solid area

Messages

Please log in to write a message.

  • 4. ledisnomad (Mar 06, 2012 15.38):

    Ah, so you aren't just looking for the right commands, but help writing the script. OK. If you are looking for weight, don't you want the solid's volume*density, not surface area*density. I took the volume, but if you really need surface area, just change that command (and variable names to match). See what you think of this:

    Option Explicit
    'Script written by Damon Sidel
    'Script copyrighted by Damon Sidel
    'Script version Tuesday, March 06, 2012

    Call Main()
    Sub Main()
           
            Dim dblConvert          : dblConvert = 1000                     'Conversion factor
            Dim strUnitsVol         : strUnitsVol = "units"         'change this to desired units
            Dim strUnitsWeight      : strUnitsWeight = "units"      'change this to desired units
           
            'USER INPUT
            'Select solid to evaluate
            Dim strObj : strObj = Rhino.GetObject("Select closed polysurface", 16, True)
            If IsNull(strObj) Then Exit Sub
           
            'Enter density of material
            Dim dblDensity : dblDensity = Rhino.GetReal("Enter the density of the material")
            If IsNull(dblDensity) Then Exit Sub
           
            'VARIABLES
            Dim arrVol, dblWeight
           
            arrVol = Rhino.SurfaceVolume(strObj)
                   
            If IsArray(arrVol) Then
                   
                    Call Rhino.Print("The polysurface volume is " & CStr(arrVol(0)) & strUnitsVol)
                   
                    dblWeight = arrVol(0) / dblDensity / dblConvert
                   
                    Call Rhino.Print("The weight of the solid is " & CStr(dblWeight) & strUnitsWeight)
                                   
            End If

    End Sub
  • 3. rosejewel (Mar 05, 2012 21.16):

    Thanks for the reply I should have been more specific at the start as you mention.
    I am using rhino 5 beta and the rhino script editor, Once I have calculated the area I wish to use it to then work out weights of materials eg nylon or wax using the formula area x density of material divided by 1000 to get the correct amount.
    As I am new to script writing you are correct the trick is how to use the commands

    The first thing is to get the object I guess use the command rhino.getobject then I think rhino.surfacearea as you mention then the calculation.
    I will try to put together the script outline with commands etc in the correct order this may be a better way of explaining it but any help would be greatly appreciated.

  • 2. ledisnomad (Mar 05, 2012 15.54):

    It would be helpful if you were a little more specific with what you want, but here's a start, maybe:

    Rhino.SurfaceArea(strObject) will calculate the area of a surface or polysurface.

    Are you using Rhino v4? Do you have the Monkey RhinoScript editor? If you do, you can often just search for a keyword like "area" and it will come up with related commands. That's how I found the command above. Then the trick is learning how to use the command!

    Good luck.

  • 1. rosejewel (Mar 04, 2012 07.51):

    Can anyone please help/advise me on where to start I am new to rhino-script and vb in general. I am trying to find the best way to calculate the area of a solid that can then be used in further math equations.

Recommend

Why are these buttons gray?