Please advise how to edit attached code so that the last messagebox appears once only.It currently appears multiple times dependingon the number of points that are selected.
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim SelMgr As SelectionMgr
Dim swPoint As SketchPoint
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set SelMgr = swModel.SelectionManager
If SelMgr.GetSelectedObjectCount = 0 Then
MsgBox "Nothing is selected!!!"
MsgBox "Please select endpoint/s."
Exit Sub
End If
Dim points As Integer
points = SelMgr.GetSelectedObjectCount2(-1)
Dim cpm As CustomPropertyManager
Dim i As Integer
For i = 1 To points
Set swPoint = SelMgr.GetSelectedObject6(i, -1)
swModel.Extension.CustomPropertyManager("").Add2 "St.Pt " & i,swCustomInfoText, "X: " & Round(swPoint.X, 5) * 1000 &vbCrLf & " Y: " & Round(swPoint.Y, 5) * 1000 '& " Z: "& swPoint.Z
MsgBox "Co-ordinates have been saved!"
Next
End SubSolidworksApi macros