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