Remove duplicate Points
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Remove duplicate Points

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
irfan
Guest





Posted: Mon Jan 31, 2005 5:22 pm    Post subject: Remove duplicate Points Reply with quote

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

Back to top
Oberer
Guest





Posted: Mon Jan 31, 2005 6:12 pm    Post subject: Re: Remove duplicate Points Reply with quote

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
Back to top
Jürg Menzi
Guest





Posted: Mon Jan 31, 2005 6:22 pm    Post subject: Re: Remove duplicate Points Reply with quote

Hi irfan

Check this link:
http://www.devx.com/vb2themax/Tip/19381

Cheers
--
Juerg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch

Back to top
irfan
Guest





Posted: Mon Jan 31, 2005 7:45 pm    Post subject: Re: Remove duplicate Points Reply with quote

thanks for the reply, i am sorted
irfan
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Contact Us
Powered by phpBB