Forgot password?

Create an account!

Forum

« back

RhinoScript – comparegeometry

Messages

Please log in to write a message.

  • 2. Hanno (Nov 02, 2009 09.34):

    Hi,

    if you still need help with this: The problem is, that your outer and inner loop both run through all your objects, so you compare them twice. You inner loop needs to run from i+1 to ubound, so that the already handled objects are not compared again.

    Regards

    Hanno

  • 1. moodo (Oct 22, 2009 15.57):

    Hey,

    I asked earlier a question about compare lines and delete duplicates ones. so I did some modifications about the script. (the comparegeometry didn't work (tolerances)).
    When I use the script some some lines dissappear (duplicates and originals), How can I solve this.

    I attached the script.
    I want to have lines and not duplicated with a color.
    Can you help me?

    Option Explicit
    'Script written by <insert name>
    'Script copyrighted by <insert company name>
    'Script version donderdag 17 september 2009 16:38:07

    Call Main()
    Sub Main()
            Dim arrpoly
            arrpoly=Rhino.getobjects("polysurfaces")
            Dim i,bcompare,n,j
            Dim markColor
            Dim toBeDeleted
            toBeDeleted=array()
            markColor=RGB(132,112,255)
            For i=0 To ubound(arrpoly)
                    bcompare=False
                    For j=0 To ubound(arrpoly)
                           
                            Dim existingCol, exCol2
                            existingCol=rhino.ObjectColor(arrpoly(j))
                            exCol2=rhino.ObjectColor(arrpoly(i))
                           
                           
                            If (j<>i) And (existingCol <> markColor) And (exCol2 <> markColor) Then
                                    Dim len1, len2
                                    len1=rhino.CurveLength(arrpoly(i))
                                    len2=rhino.CurveLength(arrpoly(j))
                                    ''rhino.Print("len"&CStr(i)&":"&CStr(len1)&" len"&CStr(j)&":"&CStr(len2))
                                    If abs (len1 - len2)<0.2 Then
                                            Dim color,color1
                           
                                            rhino.Print "Identical object "&(i)&" will be deleted"
                                            'rhino.deleteobject(arrpoly(i))
                                            ReDim Preserve toBeDeleted(uBound(toBeDeleted)+1)
                                            toBeDeleted(uBound(toBeDeleted))=arrpoly(i)
                                            color=rhino.objectcolor(arrpoly(i),markColor)
                                            Exit For
                                    End If
                                   
                                    'bcompare=rhino.CompareGeometry(arrpoly(i),arrpoly(j))
                           
                           
                            End If
                    Next
           
            Next
            For i = 0 To ubound(toBeDeleted)
                    rhino.deleteObject(toBeDeleted(i))
            Next
           

    End Sub
Recommend

Why are these buttons gray?