×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Remove duplicate point macro
2

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)

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

Hi,

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

(OP)
And how the "identifier" is created. Can you elaborate?

RE: Remove duplicate point macro

(OP)
I know that Im abusing of your kindness, but can you help me with a little piece of code?. To be honest with you, I dont really know what are you exactly talking about.

Thank you in advance.

RE: Remove duplicate point macro

thanks

Eric N.
indocti discant et ament meminisse periti

RE: Remove duplicate point macro

(OP)
Thank you very much. There's no way I could figure out this code (it seems quite advanced to me).

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources