Forgot password?

Create an account!

Forum

« back

RhinoScript – Area calculation

Messages

Please log in to write a message.

  • 5. Belishetz (Feb 05, 2014 13.11):

    Thanks Pulgarata,
    It's working.

    i believe i need to divide it by 10000, and not by 100. like this:

    Call Rhino.AddText(CStr(Round(arrAreaValue(0)/10000,2)), arrCentroidPoint(0), dblHeight)

    am i wrong?

    Is there an option for the script to remember the last entered value of the text height but still giving me the option to change it in the command? like all other rhino commands?

    thanks again,
    Hanan

  • 4. pulgarata (Feb 05, 2014 13.05):

    You are right with the division.
    For the second point, you should save the number using DocumentData. Try with this:

    Dim DefaultHeight:DefaultHeight=100
            If Not isnull(Rhino.GetDocumentData ("YourScript","HeigthSize")) Then
     DefaultHeight=CDbl(Rhino.GetDocumentData ("YourScript","HeigthSize"))
    End if
            dblHeight = Rhino.GetReal("Text height in Document units",DefaultHeight)
            Rhino.SetDocumentData "YourScript","HeigthSize",dblHeight

  • 3. Belishetz (Feb 05, 2014 12.48):

    Thanks Pulgarata,
    It's working.

    i believe i need to divide it by 10000, and not by 100. like this:

    Call Rhino.AddText(CStr(Round(arrAreaValue(0)/10000,2)), arrCentroidPoint(0), dblHeight)

    am i wrong?

    Is there an option for the script to remember the last entered value of the text height but still giving me the option to change it in the command? like all other rhino commands?

    thanks again,
    Hanan

  • 2. pulgarata (Feb 05, 2014 12.25):

    Hi Hanan,
    To set de font height write the size you want in this variable:

    dblHeight = 100

    To fix the value, change this line:

    Call Rhino.AddText (CStr(Round(arrAreaValue(0)/100, 2)), arrCentroidPoint(0) , dblHeight)

    Saludos,

  • 1. Belishetz (Feb 05, 2014 06.14):

    hi,

    i found the following script by Phil Shapiro for area calculation, but i use centimeters in my model and i want the results in meters rounded to two digits (10.00m). it would also would be nice if the script can remember the Text height.

    can someone please help me figure it out?

    Thanks,
    Hanan

    !-_RunScript
    (
    Option Explicit
    'Script written by Phil Shapiro
    'Script copyrighted by Cadlantique
    'Script version Friday, 06 August 2010 07:11:22

    Call Main()
    Sub Main()
    Dim arrCLosedCurveObjects, CurveObject, arrCentroidPoint, arrAreaValue, dblHeight

    arrClosedCurveObjects = Rhino.GetObjects("Select curve objects",4)
    dblHeight = Rhino.GetReal("Text height in Document units")

    For Each CurveObject In arrClosedCurveObjects
    If Rhino.IsCurveClosed(CurveObject) Then
    arrCentroidPoint = Rhino.CurveAreaCentroid ( CurveObject)
    arrAreaValue = Rhino.CurveArea ( CurveObject)
    Call Rhino.AddText (CStr(Round(arrAreaValue(0), 3)), arrCentroidPoint(0) , dblHeight)

    Else
    Call Rhino.SelectObject(CurveObject)
    End If

    Next
    End Sub
    )

Recommend

Why are these buttons gray?