Author Topic: Selection between 2 points but excluding any objects on the exact points.  (Read 6573 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Selection between 2 points but excluding any objects on the exact points.
« Reply #15 on: November 30, 2015, 07:14:26 AM »

Quote
directly under the line of selection

do you mean behind,  or do you mean below ?

Unless excluded by the endpoint locations I'd expect behind or in front  would be selected, not below or above.


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.

Lee Mac

  • Seagull
  • Posts: 12910
  • London, England
Re: Selection between 2 points but excluding any objects on the exact points.
« Reply #16 on: November 30, 2015, 09:04:36 AM »
With the additional conditions & selection criteria that you mention, it may be easier to follow a variation of the 'Option 1' method I suggest earlier, for example:
Code - Auto/Visual Lisp: [Select]
  1. (defun ObjectIdentification ( pt1 pt2 fuz / ang app per rtn )
  2.           ang (angle pt1 pt2)
  3.           per (- ang (/ pi 2.0))
  4.           pt1 (polar pt1 ang fuz)
  5.           pt2 (polar pt2 ang (- fuz))
  6.     )
  7.     (setq rtn
  8.         (ssget "_CP"
  9.             (list
  10.                 (polar pt1 per fuz)
  11.                 (polar pt2 per fuz)
  12.                 (polar pt2 per (- fuz))
  13.                 (polar pt1 per (- fuz))
  14.             )
  15.         )
  16.     )
  17.     (vla-zoomprevious app)
  18.     rtn
  19. )

To test:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / p q )
  2.     (if
  3.         (and
  4.             (setq p (getpoint "\n1st point: "))
  5.             (setq q (getpoint "\n2nd point: " p))
  6.         )
  7.         (sssetfirst nil (ObjectIdentification p q 1e-3))
  8.     )
  9. )

LSElite

  • Newt
  • Posts: 65
Re: Selection between 2 points but excluding any objects on the exact points.
« Reply #17 on: November 30, 2015, 05:31:58 PM »
Cheers LM, I will test it out tonight.
A life spent making mistakes is not only more honorable, but more useful than a life spent doing nothing.
― George Bernard Shaw

LSElite

  • Newt
  • Posts: 65
Re: Selection between 2 points but excluding any objects on the exact points.
« Reply #18 on: December 01, 2015, 06:21:37 AM »
It worked a treat, Cheers LM and cheers Kerry.
I learned alot over this post, and I got my problem solved  :-D
A life spent making mistakes is not only more honorable, but more useful than a life spent doing nothing.
― George Bernard Shaw

Lee Mac

  • Seagull
  • Posts: 12910
  • London, England
Re: Selection between 2 points but excluding any objects on the exact points.
« Reply #19 on: December 01, 2015, 07:46:40 AM »
Excellent to hear LSElite - you're most welcome.  :-)

And of course, if you have any questions concerning the method used in the last code posted, feel free to ask.

LSElite

  • Newt
  • Posts: 65
Re: Selection between 2 points but excluding any objects on the exact points.
« Reply #20 on: December 01, 2015, 08:07:48 AM »
And of course, if you have any questions concerning the method used in the last code posted, feel free to ask.
I was going to put it down to magic.
I think I understand though I am not certain.

It finds the internal points from the inital points.
It then zooms the screen on the internal points leaving the intial points off the screen.
It them does a selection from the initial points and skips the objects because they are off the screen?

Am I close?
A life spent making mistakes is not only more honorable, but more useful than a life spent doing nothing.
― George Bernard Shaw

Lee Mac

  • Seagull
  • Posts: 12910
  • London, England
Re: Selection between 2 points but excluding any objects on the exact points.
« Reply #21 on: December 01, 2015, 12:24:41 PM »
Close -

The function is essentially retrieving a selection using the following crossing-polygon selection window (hence the "_CP" mode string), which is offset from the supplied endpoints by the given fuzz value, and has a width equal to the given fuzz value:


LSElite

  • Newt
  • Posts: 65
Re: Selection between 2 points but excluding any objects on the exact points.
« Reply #22 on: December 01, 2015, 05:25:48 PM »
Ahhh!, Of course!
Now I get it, that is really cool.
I could be wrong but could the zoom possibly cause issues?
because it uses the internal points instead of the supplied points and moves the perpendicular points off the screen?

I think it would be an easy fix if it is an issue, to simply move the zoom to the start of the function before pt1 and pt2 are changed.
A life spent making mistakes is not only more honorable, but more useful than a life spent doing nothing.
― George Bernard Shaw

Lee Mac

  • Seagull
  • Posts: 12910
  • London, England
Re: Selection between 2 points but excluding any objects on the exact points.
« Reply #23 on: December 01, 2015, 05:54:03 PM »
I could be wrong but could the zoom possibly cause issues?
because it uses the internal points instead of the supplied points and moves the perpendicular points off the screen?

Perhaps, but in reality since the fuzz value will be very small (~1e-3 or less), this shouldn't have too much effect.

LSElite

  • Newt
  • Posts: 65
Re: Selection between 2 points but excluding any objects on the exact points.
« Reply #24 on: December 02, 2015, 06:23:01 AM »
Okay so after close inspection this program still is not giving back 100% accurate output.

I need it to remove lines that are collinear with the line made by the selection.
ie, crosses between both points.

Any Ideas?
A life spent making mistakes is not only more honorable, but more useful than a life spent doing nothing.
― George Bernard Shaw

Lee Mac

  • Seagull
  • Posts: 12910
  • London, England
Re: Selection between 2 points but excluding any objects on the exact points.
« Reply #25 on: December 02, 2015, 07:32:23 AM »
Iterate over the selection and remove those lines which do not intersect the selection line (use the inters function to test this).

LSElite

  • Newt
  • Posts: 65
Re: Selection between 2 points but excluding any objects on the exact points.
« Reply #26 on: December 02, 2015, 09:50:38 PM »
I was wrong again :(
I just need it to remove all objects on the initial points from the selection set.
I will keep playing around with my initial code but if anyone knows a better way of removing one selection set from another please let me know.
A life spent making mistakes is not only more honorable, but more useful than a life spent doing nothing.
― George Bernard Shaw

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Selection between 2 points but excluding any objects on the exact points.
« Reply #27 on: December 02, 2015, 11:28:30 PM »
Have a play

Code - Auto/Visual Lisp: [Select]
  1.  
  2.  
  3. ;; Subtracts one selection set from another and returns their difference
  4. ;; ssMain - Selection set to Subtract from
  5. ;; ssSub  - Selection set to subtract
  6.  
  7. (defun kdub:SSSubtract (ssMain ssSub / ssResult n s)
  8.   (setq n   -1
  9.         ssResult ssMain
  10.   )
  11.   (repeat (sslength ssSub)
  12.     (if (ssmemb (setq s (ssname ssSub (setq n (1+ n)))) ssResult)
  13.       (ssdel s ssResult)
  14.     )
  15.   )
  16.   ssResult
  17. )
  18.  


Image added:
« Last Edit: December 02, 2015, 11:46:03 PM 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.

LSElite

  • Newt
  • Posts: 65
Re: Selection between 2 points but excluding any objects on the exact points.
« Reply #28 on: December 03, 2015, 05:30:51 PM »
It worked perfectly.
Cheers Kerry, you are a life saver!

Here is the function if anyone wants it:
Code - Auto/Visual Lisp: [Select]
  1. (defun ObjectIdentification ( pt1 pt2 app / p1 p2 p3 p4 ang per fuz ss ss1 ss2)
  2.         ;; Subtracts one selection set from another and returns their difference
  3.         ;; ssMain - Selection set to Subtract from
  4.         ;; ssSub  - Selection set to subtract
  5.         (defun kdub:SSSubtract (ssMain ssSub / ssResult n s)
  6.                 (setq n -1 ssResult ssMain)
  7.                 (repeat (sslength ssSub)
  8.                         (if (ssmemb (setq s (ssname ssSub (setq n (1+ n)))) ssResult)
  9.                                 (ssdel s ssResult)
  10.                         )
  11.                 )
  12.         ssResult)
  13.        
  14.         (vla-zoomwindow app (vlax-3D-point pt1) (vlax-3D-point pt2))
  15.         (setq   fuz             5
  16.                         ang     (angle pt1 pt2)
  17.                         per     (- ang (/ pi 2.0))
  18.                         pnt1    (polar pt1 ang fuz)
  19.                         pnt2    (polar pt2 ang (- fuz))
  20.                         ss              (ssget "_CP"
  21.                                                 (list   (polar pnt1 per fuz)
  22.                                                                 (polar pnt2 per fuz)
  23.                                                                 (polar pnt2 per (- fuz))
  24.                                                                 (polar pnt1 per (- fuz)))
  25.                                         )
  26.         )
  27.         (if ss
  28.                 (progn
  29.                         (setq   ang1    (/ pi 4)
  30.                                         p1              (polar pt1 (* ang1 3) fuz)
  31.                                         p2              (polar pt1 (* ang1 7) fuz)
  32.                                         p3              (polar pt2 (* ang1 3) fuz)
  33.                                         p4              (polar pt2 (* ang1 7) fuz)
  34.                         )
  35.                         (vla-zoomwindow app (vlax-3D-point p1) (vlax-3D-point p2))
  36.                         (setq ss1       (ssget "_C"     p1 p2))
  37.                         (vla-zoomwindow app (vlax-3D-point p3) (vlax-3D-point p4))
  38.                         (setq ss2       (ssget "_C"     p3 p4 ))
  39.  
  40.                         (if (and ss ss1) (setq ss (kdub:SSSubtract ss ss1)))
  41.                         (if (and ss ss2) (setq ss (kdub:SSSubtract ss ss2)))
  42.                         (if ss (if (= (sslength ss) 0) (setq ss nil)))
  43.                 )
  44.         )
  45.         princ ss
  46. )
« Last Edit: December 03, 2015, 05:39:05 PM by LSElite »
A life spent making mistakes is not only more honorable, but more useful than a life spent doing nothing.
― George Bernard Shaw