[VBA,CATIA 3DExperience] Method GetCoordinates for Vertex (As SelectedElement) always returns 0,0,0

Quan PHAM

[VBA,CATIA 3DExperience] Method GetCoordinates for Vertex (As SelectedElement) always returns 0,0,0

Hello all, I'm attempting to get the coordinates of the vertex of my surfaces in CATIA 3DExperience using the method GetCoordinates in VBA but the results it gives back is always 0,0,0. Can someone point out what I'm doing wrong or if GetCoordinates is not the correct method to use at all..

Thank you in advance.

My code goes something like this:

'==============================================

Sub CATMain

'Before begining I cleaned the Body to hide all elements that I wouldn't want to select, in this case Vertex in sketches, and points for example

'And then I select a Body before continue

 

Dim selectionVertex As selection

Set SelectionVertex = CATIA.ActiveEditor.selection

selectionVertex.Search "type = Geometric Feature & Visibility=Shown;sel"

selectionVertex.Search "Topology.Vertex; sel"

'Until here everything behave correctly as I can see Catia selected the vertex I need

Dim nVertexInBody = SelectionVertex.Count

Dim vCoords(2)

 

For i=1 To nVertexInBody

   Set oVertexInBody = selectionVertex.Item(j)

   oVertexInBody.GetCoordinates vCoords

   MsgBox "Vertex's coordinates are: " &vCoords(0) & "," & vCoords(1) &"," &vCoords(2)

Next j

End Sub

Edited By:
Quan PHAM[Universite de Technologie de Compiègne] @ Nov 07, 2022 - 12:07 PM (Europe/Paris)

Little Cthulhu

RE: [VBA,CATIA 3DExperience] Method GetCoordinates for Vertex (As SelectedElement) always returns 0,0,0
(in response to Quan PHAM)

Use Measurable to get coordinates

Quan PHAM

RE: [VBA,CATIA 3DExperience] Method GetCoordinates for Vertex (As SelectedElement) always returns 0,0,0
(in response to Little Cthulhu)

Thanks Little Cthulhu for the reply, I've tried your suggestion since I've seen it on another thread but somehow it still didn't work for me. I've found out 2 problems with my code since, if anyone is still interested.

1- To get coordinates it should be : oVertexInBody.Value.GetCoordinates vCoords 

(and not oVertexInBody.GetCoordinates vCoords), this worked if the selected element is a point.

2-The bigger problem turns out to be the search method for selecting the vertex. Searching for "type = vertex" gives back pairs of points instead of each vertex (in the sense that I see it) separately. So if anyone have any suggestion on how to select the vertex (like in the photo included here..) I would greatly appreciate it.

Thanks

Attachments

  • vertex.png (50k)