Forgot password?

Create an account!

Forum

« back

RhinoScript – delete duplicate lines

Messages

Please log in to write a message.

  • 3. moos_7 (Sep 17, 2009 18.10):

    thank you.

    that helps a lot.

    gr.
    md

  • 2. Hanno (Sep 17, 2009 18.02):

    Hi,

    what you are doing is comparing each curve to itself. You need to compare each curve to every other curve in your array. The loop works like this:

    for i = 0 to ubound(arrcurve)

      bcompare = false

      for j = i + 1 to ubound(arrcurve)
        bcompare = rhino.comparegeometry(arrcurve(i), arrcurve(j))
        if bcompare then exit for
      next

      if bcompare then rhino.deleteobject(arrcurve(i))

    next

    This is a loop inside your loop, working through all the remaining curves for every curve. It is sufficient to start looking at curve i+1, because otherwise each check would be done twice (all curves < i have already been processed).


    Hope that helps!

    Hanno

  • 1. moos_7 (Sep 17, 2009 17.09):

    hey all,

    I have a bunch of lines in my model and want to find out if there are duplicates and if so delete the duplicate one.

    I tried to use the command comparegeometry(bcompare) but I don't know how to run the loop. how do I compare the lines?

    dim arrcurve
    arrcurve=rhino.getobjects("arrcurves")
    dim i,bcompare,n
    For i=0 to Ubound(arrcurve)

    bcompare=rhino.comparegeometry(arrcurve(i),arrcurve(i))
    if bcompare = true then
    rhino.deleteobject(arrcurve(i))
    Rhino.print "delete one object"
    else
    rhino.print "delete nothing"
    end if
    next
    end sub

    thank you

    gr.
    md

Recommend

Why are these buttons gray?