Forgot password?

Create an account!


« back

RhinoScript – Place 'area' value into center of shape


Please log in to write a message.

  • 14. 1605 (Aug 14, 2017 15.16):

    Rhino.AddText "text", Rhino.CurveAreaCentroid(Rhino.GetObject)(0), 10

  • 13. cdas (Aug 07, 2017 12.12):

    Sorry, I don't script but I also wanted to round the numbers as described, I end up with only errors:

    I tried dozens of edits, either with no result or with compiler errors;

    arrArea = Rhino.CurveArea(idCrv)
    Round(arrArea, 2)

    Call Rhino.AddText(CStr(Round(arrArea(0),2), arrCentroid(0))

    etc. :(

    Ideale I'd love to even automatically add a m² after the text.

  • 12. jerlu41 (Nov 30, 2016 17.24):

    Forgive my ignorance, but I'm extremely new to rhinoscript and got as far as opening up the "RhinoScript Editor" How does one create "buttons"? as you described? Amazing I'm just stumbling upon RhinoScript in 2016

  • 11. Hanno (Aug 10, 2010 17.12):

    Well, you have to thank our user ddelgiu as he is the author of the script - he will be automatically notified on new comments on his script, so adding a comment might also be a good way to ask details like the dimension multiplications.

    Btw, those are only possible if you change the "real" dimension value to a fixed number. That means if you scale the dimension object afterwards the number won't adopt to new distances anymore. It's definitely easier to scale your input geometry by 1.2 instead of changing the dimension numbers, if that's practicable for you.


  • 10. swanny (Aug 10, 2010 16.40):


    I nearly spat my coffee all over my screen when I saw this script run because I have to dimension out nearly 200 homes in a plan view. I was doing them manually. This script does all the dimensioning for me, WOW! Thanks once again for sharing.

    All I need to figure out is how to make the dimension multiply what it measures by 1.2. So if a polyline dimension is 27 it will display 32.4 in dimension. For now I'm clicking on the number and changing the ones I need manually. It should'nt be too hard to figure out. This is incredible, I love it!

  • 9. Johannes (Aug 10, 2010 11.45):

    sounds like rhinoscript is a religion and it gets a new fan! ;)

    i don't know excactly what you want to do... but take a look on that script:

    sounds similar to your project to messure a single polyline.

  • 8. swanny (Aug 10, 2010 07.04):

    Perfect, thanks!

    I applied it and now it's working.

    I'm printing out the primer and I'm going to get started on the Rhinoscript journey. I have no programing experience but I'm a believer now. Customizing Rhino like this is incredibly useful. I still need to figure out how to apply the same type of script to measure a single polyline and apply the number. I have lots to learn.

  • 7. Johannes (Aug 09, 2010 09.46):

    hi, there are some easy functions for it.

    Cint(321.6456) -> 322
    Round(321.6456, 2) -> 321.65
    Round(321.6456, 1) -> 321.6


  • 6. swanny (Aug 09, 2010 01.18):

    Hi Hanno,

    Is there an easy way to reduce or average the length of the number I get for the area?

    For example 321.645635212 to 321 ?



  • 5. swanny (Aug 06, 2010 06.06):

    Hanno -

    This has saved me days and hours of time for a huge ongoing project I have. I can't thank you enough!

    I made 8 buttons with the script corresponding to 8 different roof piches. Now I just click on the button that corresponds to the pitch of the roof facet, click on a roof facet and I get the correct area. It works awesome!

    Lastly I just need to figure out how to apply this script to dimension the 'length' a polyline. So I can measure or dimension a polyline have it be multiplied by 1.2 (the pitch) and apply the text onto the poly line. If you have any tips that would be appreciated.

    Of course, eitherway thanks again for all your help with the area stuff.



  • 4. Hanno (Aug 04, 2010 22.54):

    arrArea(0) is your area, so you can simply change that



    CStr(arrArea(0) * 1.12)

    (btw: the CStr() simply converts the numeric value into a string for printing)

  • 3. swanny (Aug 04, 2010 17.33):


    You are the man! This is exactly what I was trying to do. I promise I will reverse engineer your script and learn how this is done. Incredible.

    Could I bother you for one more thing? I'm realizing I need to account for the pitch of the roof in regards to the area calculation. For instance, if the sum of the flat area = 24 I need to mulipy it by 1.12(which is a 6/12 roof pitch).

    So, in other words is there a way to multiply the area value by 1.12 in the script?

    Thanks Again


  • 2. Hanno (Aug 04, 2010 16.47):

    Hi there,

    you are right, that's exactly the kind of task where scripting comes in handy.
    Now normally I would try to get you writing it yourself, but as you are completely new to Rhinoscript and I have some minutes waiting for another script to run through right now:

    Dim idCrv, arrArea, arrCentroid

    idCrv = Rhino.GetObject("Closed planar curve", 4) ' 4 = rhObjectCurve
    If Not isnull(idCrv) Then
            If Rhino.IsCurveClosed(idCrv) And Rhino.IsCurvePlanar(idCrv) Then
                    arrArea = Rhino.CurveArea(idCrv)
                    arrCentroid = Rhino.CurveAreaCentroid(idCrv)
                    If Not isnull(arrArea) And Not isnull(arrCentroid) Then
                            Call Rhino.AddText(CStr(arrArea(0)), arrCentroid(0))
                    End If
            End If
    End If

    This is simple enough and does the job for one curve. Have a look at the RhinoScript Primer (see links section) and try to understand the above script and then change/enhance it (for example by enclosing it in a Loop to make it work with more than one curve) until it fits your needs...

    Good luck!


  • 1. swanny (Aug 03, 2010 22.03):

    Hey guys,

    I'm doing a 2D drafting job (no 3D, just top view with connected polylines), I need to find the 'area' calculation and place that calcualtion(text)into the center of each shape. Usually there are between 7-15 closed shapes that I need to find the area of. Think 'Tetris' and placing the area text into the middle of each rectangular shape.

    Right now I select the closed polyline shape, click 'area', copy the calcualation from the command box, click 'text', copy the paste the area into it and move the number into the middle of the polyline shape.

    I need to figure out how to automate this. Basically click on the shape, run the script and have it place the area calculation in the middle of the shape. Actually being able to do all the shapes at the same time would be even better, but I don't want to get greedy

    Sounds simple but I don't know Rhinoscript at all. Any help would be appreciated!


Why are these buttons gray?