Forgot password?

Create an account!

Forum

« back

RhinoScript – How do I use CurveArea to assign color??

Messages

Please log in to write a message.

  • 2. Johannes (Mar 05, 2013 08.50):

    Hi, the return value of Rhino.CurveArea() is an array. That's why you get the mismatch. area(0) is the area.
    Variable declaration should be outside the loop, there is a typo in percent - precent, there is no check if it is a closed and planar curve (otherwise error), there is a typo in Rhino.ObjectColor(... and maybe a call mssing infront of the last function.

    Johannes

  • 1. jess_collier84 (Mar 04, 2013 20.12):

    I am trying to generate colored lines according to area of the polyline. Using a very simple script, getting a mismatch error.

    Option Explicit
    'Script written by <insert name>
    'Script copyrighted by <insert company name>
    'Script version Sunday, March 03, 2013 11:54:39 PM

    Call Main()
    Sub Main()
            Dim crvs, crv, max
            crvs = Rhino.GetObjects("select curves",4)
            max = Rhino.GetReal("max area",8)

            For Each crv In crvs
                    Dim area, precent
                    area = Rhino.CurveArea(crv)
                    percent = area/max
                    If percent > 1 Then
                            percent = 1
                    End If
                    Rhino.ObjectColorcrv, RGB( 255*percent, 0, 255*(1-percent))
            Next
    End Sub
Recommend

Why are these buttons gray?