Forgot password?

Create an account!

Forum

« back

RhinoScript – surface normals

Messages

Please log in to write a message.

  • 5. moodo (Sep 24, 2009 21.09):

    found it.

    thanks.

  • 4. moodo (Sep 23, 2009 19.52):

    hi,

    The first part I can do, but I same some problems with the second part, how
    can you write this part?

    gr.
    md

  • 3. Hanno (Sep 23, 2009 18.18):

    Hi,

    you are mixing up your loops... try to divide your script into two parts:

    1. collect all the normals. You need to first dim an arrNormals array of sufficient size and then do a simple loop through all your surfaces, collecting the normals.

    2. Then you can compare all the normal directions. You can simply compare arrNormals(i) to arrNormals(j), because all the values have been calculated in the first part.

    Hope that helps!

    Hanno

  • 2. moodo (Sep 22, 2009 00.07):

    addition on the message below:

    I select 2 irregular polysurface
    I changed the explodepolysurfaces(arrobjects,true)
    so I don't get doublicate surfaces anymore.

    But the whole irregular polygsurfaces will be coloured, instead of different colors, the surfaces in polysurfaceA haven't the same surfacenormal as the surfaces in polysurfacesB, so several surfaces must kept their old color?

  • 1. moodo (Sep 21, 2009 23.55):

    hi all,

    I have a question about changing the color of a surface when they have the same surfacenormal. So I made two loops were I compared the surfacenormals, then I wrote if arrnormal=arrnormal 1 then
    I want to change the color of these surfaces (with the same surfacenormal)

    I get several surfaces with different colors, but I want no duplicates, I just want to change the color of the surfaces wich surfacenormal are equal.

    How can I solve this.
    thanks.

    gr.
    md.

    Option Explicit
    'Script written by <insert name>
    'Script copyrighted by <insert company name>
    'Script version maandag 21 september 2009 23:19:24

    Call Main()
    Sub Main()
            Dim arrobjects,arrexplode
            arrobjects=rhino.getobjects("select polysurfaces",16)
            arrexplode=rhino.ExplodePolysurfaces(arrobjects)
           
            Dim arrpoint,arrparam,arrnormal,i,strobject
            For i=0 To Ubound(arrexplode)
                    arrPoint = Rhino.SurfaceAreaCentroid(arrexplode(i))
                    If IsArray(arrPoint) Then
                            arrParam = Rhino.SurfaceClosestPoint(arrexplode(i), arrPoint(0))
                            arrNormal = Rhino.SurfaceNormal(arrexplode(i), arrParam)
                            Rhino.Print Rhino.Pt2Str(arrNormal)
                    End If
                    Dim arrpoint1,arrparam1,arrnormal1,j
                   
                    For j=i+1 To Ubound(arrexplode)
                            arrpoint1=rhino.SurfaceAreaCentroid(arrexplode(j))
                            If Isarray(arrpoint1) Then
                                    arrparam1 = rhino.SurfaceClosestPoint(arrexplode(j),arrpoint1(0))
                                    arrnormal1 = rhino.surfaceNormal(arrexplode(j),arrparam1)
                                    rhino.Print rhino.pt2str(arrnormal1)
                            End If
                            ReDim Preserve arrnormal(i)
                            ReDim Preserve arrnormal1(j)
                            If arrnormal(i)=arrnormal1(j) Then
                                    Rhino.ObjectColor arrexplode(i), RGB(250,250,100-5*i)
                                    rhino.objectColor arrexplode(j), RGB(250,250,100-5*1)
                            Else
                                    i=i+1
                            End If
                   
                    Next
            Next
    End Sub
Recommend

Why are these buttons gray?