Author Topic: Selection of Object by Point  (Read 1670 times)

0 Members and 1 Guest are viewing this topic.

GumbyCAD

  • Newt
  • Posts: 84
Selection of Object by Point
« on: February 18, 2014, 10:20:04 PM »
In the old LISP days you could select a line with the Nearest OSNAP turned on and return the object that was selected by that point.

Code: [Select]
(setq pt (getpoint "\nPick a point"))
(setq ss (ssget pt))

Does anyone have a .NET equivalent for this?

Thanks in advance

Jeff H

  • Needs a day job
  • Posts: 6151
Re: Selection of Object by Point
« Reply #1 on: February 18, 2014, 11:41:29 PM »
Editor.GetPoint

GumbyCAD

  • Newt
  • Posts: 84
Re: Selection of Object by Point
« Reply #2 on: February 19, 2014, 12:04:17 AM »
So far I have compiled this function based on some googling....

Seams complicated.......

Code: [Select]

    Private Function GetObjectAtPoint(ByVal P As Point3d) As ObjectId

        Dim vd As Vector3d = New Vector3d(0.0001, 0.0001, 0.0001)
        Dim pMin As Point3d = P - vd
        Dim pMax As Point3d = P + vd
        Dim tvs() As TypedValue = New TypedValue() {New TypedValue(0, "LWPOLYLINE")}
        Dim points As Point3dCollection = New Point3dCollection
        points.Add(pMin)
        points.Add(pMax)
        Dim sf As SelectionFilter = New SelectionFilter(tvs)
        Dim sres As PromptSelectionResult = Ed.SelectFence(points, sf)
        If sres.Status <> PromptStatus.OK Then
            Ed.WriteMessage("Wrong selection!")
            Return ObjectId.Null
        End If

        If sres.Value.Count = 0 Then
            Ed.WriteMessage("Nothing selected!")
            Return ObjectId.Null
        End If

        Return sres.Value.GetObjectIds(0)

    End Function

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Selection of Object by Point
« Reply #3 on: February 19, 2014, 12:29:10 AM »
I can't make time to play, but I thought we could do it with something like
Code - C#: [Select]
  1. ed.SelectCrossingWindow(point, point, filter);

added:
are you sure there isn't a SelectAtPoint method ??

added:
looks like not ... old age is catching up with me.
« Last Edit: February 19, 2014, 12:39:05 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Selection of Object by Point
« Reply #4 on: February 19, 2014, 12:54:53 AM »
This may give you some ideas :

SelectSomewhereNearPoint(Point3d point)

http://www.theswamp.org/index.php?topic=36317.msg414127#msg414127
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

GumbyCAD

  • Newt
  • Posts: 84
Re: Selection of Object by Point
« Reply #5 on: February 19, 2014, 01:04:14 AM »
Thanks guys

Jeff H

  • Needs a day job
  • Posts: 6151
Re: Selection of Object by Point
« Reply #6 on: February 19, 2014, 02:34:15 AM »
Sorry GumbyCAD,

I meant GetEntity, but I still think I missed understood the question, but luckily we got guys like Kerry to keep us in line.


GumbyCAD

  • Newt
  • Posts: 84
Re: Selection of Object by Point
« Reply #7 on: February 19, 2014, 02:50:03 AM »
No Stress Jeff, I am just happy people are there to try and help.  8-)