AnsweredAssumed Answered

Problem with GetSelectionPoint2

Question asked by J. R. on Mar 5, 2018
Latest reply on Mar 5, 2018 by J. R.

Hello,

 

A part of macro I'm making has to select a point by it's ID (sketch point, geometry point, Center of Mass point, etc.) and output it's coordinates. I'm using GetSelectionPoint2 method, testing it out on a sketch point (for now), with the following code:

 

Function GetCGdifferences()
    Dim SelPt As Variant
    
    boolstatus = swModel.Extension.SelectByID2("Point1@SET Center of Mass", "EXTSKETCHPOINT", 0, 0, 0, False, 0, Nothing, 0)
    SelPt = swSelMgr.GetSelectionPoint2(1, -1)
    
    Debug.Print SelPt(0)
    Debug.Print SelPt(1)
    Debug.Print SelPt(2)
End Function

 

However, for whatever reason, this code doesn't work - it selects the point, but the output is 0, 0, 0. Now, most surprisingly, if I select the point manually, the GetSelectionPoint2 outputs the proper coordinates. In fact, if I replace the 4th line with:

 

boolstatus = swModel.Extension.SelectByID2"Point1@SET Center of Mass", "EXTSKETCHPOINT", 0.370861965642898, -0.109938984318898, 2.58003532522887, False, 0, Nothing, 0)

 

then the GetSelectionPoint2 also outputs the correct coordinates. The difference in that line is that the selection is overiden by selection coordinates (I got them by recording a macro).

 

This is most puzzling for me, because I don't understand why the GetSelectionPoint2 is so picky about the way I select that point that I need to extract coordinates from. Can someone please point out my mistake? Why isn't the initial code working?

 

Thank you in advance.

Outcomes