Remove duplicate point macro
Remove duplicate point macro
(OP)
Hi:
I'be trying to develop a macro to remove duplicated points. So far I can manage to extract the coordinates of all points in the whole part or geometrical set. Can someone give a hand, at this point I feel that Im stuck. Here is one portion of the code (don't mind if something is weird/wrong, i've been experimenting a lot but essentially the code is for coordinates extraction)
I'be trying to develop a macro to remove duplicated points. So far I can manage to extract the coordinates of all points in the whole part or geometrical set. Can someone give a hand, at this point I feel that Im stuck. Here is one portion of the code (don't mind if something is weird/wrong, i've been experimenting a lot but essentially the code is for coordinates extraction)
CODE -->
Sub catmain()
Dim oPart As PartDocument
Set oPart = CATIA.ActiveDocument
'=====================================================
'Declare variables
Dim objPart As Part
Dim objHSF As HybridShapeFactory
Dim objRef As Reference
'Get at the part and its HybridShapeFactory object
Set objPart = CATIA.ActiveDocument.Part
Set objHSF = objPart.HybridShapeFactory
'=====================================================
Dim oSel As Selection
Set oSel = CATIA.ActiveDocument.Selection
oSel.Search ("Type=Point,all")
Dim counter As Integer
counter = oSel.Count
MsgBox counter
Dim i As Integer
Dim acoord(2)
Dim acoord2(2)
For i = 1 To oSel.Count
Dim dummy
Set dummy = oSel.Item(i).Value
dummy.GetCoordinates acoord
acoord2(i) = acoord(i)
'MsgBox "X coordinate: " & acoord(0) & vbCrLf & "Y coordinate: " & acoord(1) & vbCrLf & "Z coordinate: " & acoord(2)
Next i
MsgBox acoord2(1) & vbCrLf & acoord2(2)
If acoord2(1) >= acoord(1) And acoord2(2) >= acoord(2) Then
'oSel.delete
Set objRef = objPart.CreateReferenceFromObject(objPart.FindObjectByName("asd"))
End If
End Sub
'Dim oPart As PartDocument
'Set oPart = CATIA.ActiveDocument
'Dim oSel As Selection
'Set oSel = CATIA.ActiveDocument.Selection
'oSel.Search ("Type=Edge,all")
'Dim counter As Integer
'counter = oSel.Count
'MsgBox counter 




RE: Remove duplicate point macro
For the time being I would give an identifier to the points and after that check if there are points with same coordinates. Using identifiers for points will allow you to delete them. Otherwise, how macro should know what to delete ?
Do a test with your code for just 3 points in same location and you will have another kind of error...try to understand why.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Remove duplicate point macro
RE: Remove duplicate point macro
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Remove duplicate point macro
Thank you in advance.
RE: Remove duplicate point macro
indocti discant et ament meminisse periti
RE: Remove duplicate point macro
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Remove duplicate point macro
indocti discant et ament meminisse periti
RE: Remove duplicate point macro