' return the primitive under the given position in pixels
' return nothing if no entity at this position   

'Entity GetPrimitiveAtPoint(Point pt)

Sub main()

    Dim ent As Entity

    Dim p As New Point(100, 100)  ' a pixel position on the view ; x=100, y=100

    Try
        ent = CamBamUI.MainUI.ActiveView.GetPrimitiveAtPoint(p)

        ThisApplication.AddLogMessage("Entity # " & ent.ID)
        ThisApplication.AddLogMessage("Type # " & ent.PrimitiveType)

    Catch ex As Exception

        MsgBox("No entity under this pixel coordinates")

    End Try

End Sub