Author Topic: Question about selecting an object from a point  (Read 5493 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Question about selecting an object from a point
« Reply #15 on: January 07, 2011, 05:58:31 AM »
Have a play with something like this
Code: [Select]
[color=green];; bd1.lsp[/color]
(defun [color=blue]c:bd1[/color] (/ Limit Pre Pt1 Sel Xpt1 Ypt1)
  (vl-load-com)
  [color=green];; sample by kdub@theSwamp
  ;; Select an object at or in in a relative position to the selected Point.
  ;; If the Object is not found, change the point negative X vector 0.01
  ;; untill the search limit is reached
  ;; Will only select object if the point is ON screen.[/color]
  (setq pt1   (getpoint [color=Maroon]"\nPoint to Test:"[/color])
        pre   0.01
        xpt1  (car pt1)
        ypt1  (cadr pt1)
        limit (- xpt1 15)
  )
  (vl-cmdf [color=Maroon]"zoom"[/color] [color=Maroon]"E"[/color])
  (while (and (> xpt1 limit)
              (not (setq SEL (nentselp [color=Maroon]""[/color] (list xpt1 ypt1))))
         )
    (setq xpt1 (- xpt1 pre))
  )
  (vl-cmdf [color=Maroon]"zoom"[/color] [color=Maroon]"P"[/color])
  SEL
)
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.

Brick_top

  • Guest
Re: Question about selecting an object from a point
« Reply #16 on: January 07, 2011, 06:17:17 AM »
thanks a lot for your code

Unfortunately I've not been able to understand if it is working or not

It prompts me to an entity name and a coordinate of the point I picked right?

Brick_top

  • Guest
Re: Question about selecting an object from a point
« Reply #17 on: January 07, 2011, 06:25:41 AM »
if I remove the vl-cmdf parts it gives me the coordinate of the object I want to select

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Question about selecting an object from a point
« Reply #18 on: January 07, 2011, 06:27:24 AM »
Retutns the value of SEL

If it works :
returns the entity and pickpoint from nentselp

if it fails :
returns nil

//-----------------------
The entity MAY NOT be at the point selected.

Please note  the selection functions return the point selected but select onjects inside the pickbox.

The example shown is using a circle with a 10.0 radius ... the selected point was (-9.87 0.0 0.0) and the circle circumference was just in the pickbox.

There are several ways to determine the actual entity point  ... but will not be required if you only want the entity.
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: Question about selecting an object from a point
« Reply #19 on: January 07, 2011, 06:31:44 AM »
if I remove the vl-cmdf parts it gives me the coordinate of the object I want to select


NO !

removing the Zoom commands will just stop the point being selected if it's off screen.


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.

Brick_top

  • Guest
Re: Question about selecting an object from a point
« Reply #20 on: January 07, 2011, 06:34:31 AM »
I removed the declared variable sel to test from the command line what entity it was but it isn't the one I want

But if I remove the vl-cmdf parts it selects the entity I expect it to select, it if is on screen

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Question about selecting an object from a point
« Reply #21 on: January 07, 2011, 06:39:14 AM »
I removed the declared variable sel to test from the command line what entity it was but it isn't the one I want

But if I remove the vl-cmdf parts it selects the entity I expect it to select, it if is on screen

Everything will work just as you expect it to, unless your expectations are incorrect. 
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: Question about selecting an object from a point
« Reply #22 on: January 07, 2011, 06:45:38 AM »
But if I remove the vl-cmdf parts it selects the entity I expect it to select, it if is on screen

I will select the correct entity with the zoom commands left in ..

I removed the declared variable sel to test from the command line what entity it was but it isn't the one I want

Care to explain this in more detail. ?
Is the entity within the 'limit' distance as nominated in the code ?
(if a limit is not expressed, the code will continue untill it runs out of memory or finds something 5 kilometers away)
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.

Brick_top

  • Guest
Re: Question about selecting an object from a point
« Reply #23 on: January 07, 2011, 06:47:41 AM »
I guess I have found out what I was doing wrong

I was testing without a closed object, when I try your routine with a closed polyline it works

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Question about selecting an object from a point
« Reply #24 on: January 07, 2011, 06:51:04 AM »
I guess I have found out what I was doing wrong

I was testing without a closed object, when I try your routine with a closed polyline it works

NO!

a closed object is NOT required.


Please don't make assumptions based on limited and possibly faulty testing ... you'll remain sane longer :)
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.

Brick_top

  • Guest
Re: Question about selecting an object from a point
« Reply #25 on: January 07, 2011, 06:53:42 AM »
but when I don't use a closed object it "doesn't select the next object in the -x direction" In case this was what it was expected to do

I'm sorry for all the trouble

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Question about selecting an object from a point
« Reply #26 on: January 07, 2011, 06:55:30 AM »
but when I don't use a closed object it doesn't select the next object in the -x direction

I'm sorry for all the trouble

Can you post a drawing of the data you've using, and a description of what you expect.

What do you mean NEXT object ... there was never discussion of a NEXT object  :|
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.

Brick_top

  • Guest
Re: Question about selecting an object from a point
« Reply #27 on: January 07, 2011, 07:02:38 AM »
I'm sorry for not being clear enough

I was trying to select the next object in the -x direction from picked point



« Last Edit: January 07, 2011, 07:06:20 AM by Brick_top »

Brick_top

  • Guest
Re: Question about selecting an object from a point
« Reply #28 on: January 07, 2011, 07:05:55 AM »
Here is the drawing

Brick_top

  • Guest
Re: Question about selecting an object from a point
« Reply #29 on: January 07, 2011, 07:07:58 AM »
there might be a precision error, because if I test this in a drawing with a smaller zoom extents area it works as I was expecting, which was for it to select the "next" object in the -x direction from the picked point