Remove duplicate Points

Discussion in 'AutoCAD' started by irfan, Jan 31, 2005.

  1. irfan

    irfan Guest

    I was wondering if someone has already written code to remove duplicate points from a collection before i spend time to write it form scratch


    TIA
    irfan
     
    irfan, Jan 31, 2005
    #1
  2. irfan

    Oberer Guest

    Mike Tuersley wrote (in the thread below):
    Code:
    On Error Resume Next
    MyCollection.Add "x:y:z"
    If Err.Number <> 0 Then Err.Clear
    
    He also wrote:
    Code:
    What you are looking to do at least point-wise is simple. Here run this
    example using a collection [watch for wordwrap]:
    
    Sub Test()
    Dim cPoints As Collection
    Set cPoints = New Collection
    
    Dim iIndex As Integer
    Dim dPt() As Double
    
    For iIndex = 1 To 5
    'get point
    dPt = ThisDrawing.Utility.GetPoint(, "Select point number " & iIndex &
    ": ")
    'the point is added to the collection - the "point" itself is the
    object and
    'the concatenation of X_Y_Z is the key to ensure the points are unique
    'NOTE: Don't try inputing the same point twice UNLESS you incorporate
    the
    'error trap below
    cPoints.Add dPt, dPt(0) & "_" & dPt(1) & "_" & dPt(2)
    
    Next
    
    'now try to re-add the last point...if you step thru it, you'll see an
    'error fires so the point isn't added
    On Error Resume Next
    cPoints.Add dPt, dPt(0) & "_" & dPt(1) & "_" & dPt(2)
    If Err.Number <> 0 Then Err.Clear
    
    'now lets use the points
    Dim oLine As AcadLine
    
    For iIndex = 1 To 4
    Set oLine = ThisDrawing.ModelSpace.AddLine(cPoints.Item(iIndex),
    cPoints.Item(iIndex + 1))
    oLine.color = iIndex
    Next
    
    End Sub
    -- Mike
    
    See more tips @:
    http://discussion.autodesk.com/thread.jspa?threadID=378656
     
    Oberer, Jan 31, 2005
    #2
  3. irfan

    Jürg Menzi Guest

    Jürg Menzi, Jan 31, 2005
    #3
  4. irfan

    irfan Guest

    thanks for the reply, i am sorted
    irfan
     
    irfan, Jan 31, 2005
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.