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

0 Members and 1 Guest are viewing this topic.

Brick_top

  • Guest
Question about selecting an object from a point
« on: December 28, 2010, 06:02:12 AM »
I'm trying to select an object from a selected point, I'm able to do it but only if the object is on screen

Here is the code
Code: [Select]
(defun c:bd ()
   (setq pt1 (getpoint "\nPonto para detectar ilha:")
         pre 0.0001
         xpt1 (car pt1)
         ypt1 (cadr pt1)
         ss1 nil
   )
   (while       
       (if
          (= (setq ss1 (ssget (list xpt1 ypt1))) nil)
              (setq xpt1 (- xpt1 pre))
         
       );if                 
   );while
)

I'm only testing in "-x" direction.

How can I select the object if it is "off screen"?

Off Topic - Also would it be better to stop creating topics? I have three already with this one

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Question about selecting an object from a point
« Reply #1 on: December 28, 2010, 06:09:17 AM »
Off Topic - Also would it be better to stop creating topics? I have three already with this one

I assume you mean 'three including this one'

That seems fine to me ... If they were all related to the same topic someone will probably have a little whinge though.

The topic is well named, so that will save you some grief. ;)
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 #2 on: December 28, 2010, 06:11:33 AM »
I found out that I can just zoom to extents and it will select the object with no problem.

So this is not a problem anymore

It would be interesting to see if anyone has the answer though

Thanks a lot

Brick_top

  • Guest
Re: Question about selecting an object from a point
« Reply #3 on: December 28, 2010, 06:13:43 AM »
Off Topic - Also would it be better to stop creating topics? I have three already with this one

I assume you mean 'three including this one'

That seems fine to me ... If they were all related to the same topic someone will probably have a little whinge though.

The topic is well named, so that will save you some grief. ;)

Yeah that was what I meant!

My english could be better

Thanks for the clarification

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Question about selecting an object from a point
« Reply #4 on: December 28, 2010, 12:53:29 PM »
Another way would be to use nentselp

DEVITG

  • Bull Frog
  • Posts: 479
Re: Question about selecting an object from a point
« Reply #5 on: December 31, 2010, 06:04:17 PM »
I'm trying to select an object from a selected point, I'm able to do it but only if the object is on screen

Here is the code
Code: [Select]
(defun c:bd ()
   (setq pt1 (getpoint "\nPonto para detectar ilha:")
         pre 0.0001
         xpt1 (car pt1)
         ypt1 (cadr pt1)
         ss1 nil
   )
   (while       
       (if
          (= (setq ss1 (ssget (list xpt1 ypt1))) nil)
              (setq xpt1 (- xpt1 pre))
         
       );if                 
   );while
)

I'm only testing in "-x" direction.

How can I select the object if it is "off screen"?

Off Topic - Also would it be better to stop creating topics? I have three already with this one


SSGET works only with object on screen , except by( ssget  ¨X¨

You can do a ZOOM center point

Location @ Córdoba Argentina Using ACAD 2019  at Window 10

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Question about selecting an object from a point
« Reply #6 on: January 06, 2011, 06:33:05 PM »
My suggestion is to use something like the following (unless there is more than one object at the point):
Code: [Select]
(defun c:bd ()
   (setq pt1 (getpoint "\nPonto para detectar ilha:")
         pre 0.0001
         xpt1 (car pt1)
         ypt1 (cadr pt1)
         ss1 nil
   )
   (while       
       (if
          (= (setq ss1 (nentselp "" (list cpt1 ypt1)) nil)
              (setq xpt1 (- xpt1 pre))
         
       );if                 
   );while
)
This should select items off the screen as well.

Brick_top

  • Guest
Re: Question about selecting an object from a point
« Reply #7 on: January 07, 2011, 04:21:06 AM »
thats interesting, i have to look into that nentselp "" part, I don't know about.

but yeah there is one more object at that point, and that is a closed polyline. I have to check if pt1 is inside the selected closed polyline and if not select another one.

I found a routine that checks if a point is inside a closed polyline but, I'll have to understand how it works

thanks for all the help guys
« Last Edit: January 07, 2011, 05:27:02 AM by Brick_top »

Brick_top

  • Guest
Re: Question about selecting an object from a point
« Reply #8 on: January 07, 2011, 04:53:12 AM »
apparently it isn't working, I typed the missing parenthesis and corrected the misspelled variable
Code: [Select]
(defun c:bd ( / ss1)
   (setq pt1 (getpoint "\nPonto para detectar ilha:")
         pre 0.01
         xpt1 (car pt1)
         ypt1 (cadr pt1)
   )
   (while       
       (if
          (= (setq ss1 (nentselp "" (list xpt1 ypt1))) nil)
              (setq xpt1 (- xpt1 pre))
         
       );if                 
   );while
)

it works if the object is onscreen
« Last Edit: January 07, 2011, 05:14:19 AM by Brick_top »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Question about selecting an object from a point
« Reply #9 on: January 07, 2011, 05:10:14 AM »
apparently it isn't working,

Brick_top
Do you know what that code is doing ??
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 #10 on: January 07, 2011, 05:19:26 AM »
I haven't really understood the part of the nentselp.

It is changing the value of the x coordinate until it selects an object. I wrote the code, I just don't understand the tip about the nentselp.

edit - but I guess that the user that gave the tip was trying to tell me how to select the object if it is offscreen

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Question about selecting an object from a point
« Reply #11 on: January 07, 2011, 05:31:53 AM »

Does it select objects on 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 #12 on: January 07, 2011, 05:35:25 AM »
yes it does

I guess I can just do a zoomextents
« Last Edit: January 07, 2011, 05:48:06 AM by Brick_top »

Brick_top

  • Guest
Re: Question about selecting an object from a point
« Reply #13 on: January 07, 2011, 05:45:09 AM »
I tried doing zoom extents
Code: [Select]
(defun c:bd ()
   (setq pt1 (getpoint "\nPonto para detectar ilha:")
         pre 0.01
         xpt1 (car pt1)
         ypt1 (cadr pt1)
         ss1 nil
   )
 (command "zoom" "E")
   (while       
       (if
          (= (setq ss1 (ssget (list xpt1 ypt1))) nil)
              (setq xpt1 (- xpt1 pre))           
       );if                 
   );while
 (command "zoom" "P")

)

But I guess this introduces some kind of precision error since it selects objects in other directions

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Question about selecting an object from a point
« Reply #14 on: January 07, 2011, 05:50:11 AM »
yes,
Selecting objects using a point off screen has always been an issue.

regarding your code ... I'll be back is a bit ..
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.