Product : Engine, Version : 5.1.1.1038, ArticleID : 41024109

HowTo : Get the nearest entity from a point

Article41024109
TypeHowTo
ProductEngine
Version5.1.1.1038
Date Added9/29/2005
Submitted byHans Leirvik
Keywords

Subject

Get the nearest entity from a point

Summary

Get the nearest entity from a point

Solution

This article explains how to get the nearest entity to a given point.

Dim pt          As Variant
Dim npt         As Variant
Dim fig         As vdFigure
Dim tmpPick     As Integer
tmpPick = VDPro1.PickSize
VDPro1.PickSize = 2000

pt = VDPro1.Utility.GetPoint
VDPro1.Utility.getOsnapPoint pt, 0, VdProlib5.VdOsnapNearest, npt
VDPro1.PickSize = 1
If Not IsEmpty(npt) Then
    Set fig = VDPro1.ActiveDocument.GetEntityFromPOINT(npt)
    If Not (fig Is Nothing) Then
         dist = VDPro1.Utility.geomDistance(pt, npt)
         fig.HighLight = VdHightLightDot
         fig.Invalidate
         MsgBox "Found : " & fig.Handle & " in " & CStr(dist) & " D.U."
    End If
End If
VDPro1.PickSize = tmpPick