<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Selection behavior assistance in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12525548#M18541</link>
    <description>&lt;P&gt;one thought I have but only let's user select window once and then the program continues so no more additional selections. Replace these lines of code:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;  (if
    (and (setq sel (ssget))
         (setq box (LM:ssboundingbox sel))
    )&lt;/LI-CODE&gt;&lt;P&gt;with these:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;  (princ "\nSelect Objects by Window")
  (setq p1 (getpoint "\nFirst Corner: "))
  (setq p2 (getcorner p1 "\nSecond Corner: "))
  (if
    (and (setq sel (ssget "_W" p1 p2))
         (setq box (LM:ssboundingbox sel))
    )&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 29 Jan 2024 02:18:41 GMT</pubDate>
    <dc:creator>paullimapa</dc:creator>
    <dc:date>2024-01-29T02:18:41Z</dc:date>
    <item>
      <title>Selection behavior assistance</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12525375#M18540</link>
      <description>&lt;P&gt;&lt;BR /&gt;This neat program came to the top of the stack recently and I've been trying it, but in testing found one undesirable - selection from right to left invokes the usual crossing selection, which can make for some surprises when the odd line or two extends to the horizon.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using Autocad 2022&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In further testing, I discovered when the program runs and is waiting for user selection to begin, I can enter the word WINDOW in the command line and, regardless of direction, selection is only of objects completely enclosed by the selection box. Just the thing!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alternatively, at this same point in the program, I can click on the SELECT WINDOW button on a toolbar for the same results and again, regardless of direction, selection is only of objects completely enclosed by the selection box.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot, though, for the last few days of searching for ideas and trial-and-error, find or figure a way to add this to the program.&lt;BR /&gt;I'm wanting to eliminate the need for those extra steps and to avoid ever dealing with crossing selection characteristics for this program.&lt;BR /&gt;The intent is to share this with co-workers, but it would be better if the selection type was always WINDOW and never CROSSING.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to add this trait to the program?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;;;
;; Original program by LeeMac 23OCT2013
;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/the-smallest-rectangle-enclosing-selected-set-of-objects/td-p/3791519
;; Message 10
;; 
;; Mods by SteveJ 24JAN2024 to replace an old program that really didn't
;;   work all that well:
;; 0. Renamed from 'test' to TBOX to replace old program of same name.
;; 1. Hard set offset from selected objects based on text size.
;; 2. In LM:ssboundingbox routine, changed l, u and r in variables
;;    to upper case, mostly to eliminate 1/l confusion and figured
;;    while I was there, might as well do the others. 
;; Works for ANY entity, including block references, and that's a most useful bonus.
;; Also removed lines of code made nonessential by my changes.
 
(defun c:TBOX (/ box off sel)

  (if (member (getvar "textsize") '(0.08 0.12 0.14 0.16)); IF text height is set to one of these
    (setq bbox:offset 0.08); THEN set offset = 0.08 = 1/12 scale
    (setq bbox:offset 0.96); ELSE set offset = 0.96 = full scale
  )
    (setq off bbox:offset)

  (if
    (and (setq sel (ssget))
         (setq box (LM:ssboundingbox sel))
    )
    (entmake
      (list
        '(000 . "LWPOLYLINE")
        '(100 . "AcDbEntity")
        '(100 . "AcDbPolyline")
        '(090 . 4) ; Number of vertices
        '(070 . 1) ; Closed Polyline
        (list 10 (- (caar box) off) (- (cadar box) off))
        (list 10 (+ (caadr box) off) (- (cadar box) off))
        (list 10 (+ (caadr box) off) (+ (cadadr box) off))
        (list 10 (- (caar box) off) (+ (cadadr box) off))
      )
    )
  )
  (princ)
)
;; Selection Set Bounding Box  -  Lee Mac
;; Returns the lower-left and upper-right WCS points of a rectangle
;; bounding all objects in a supplied selection set
(defun LM:ssboundingbox (ss / i L1 L2 LL UR)
  (repeat (setq i (sslength ss))
    (vla-getboundingbox (vlax-ename-&amp;gt;vla-object (ssname ss (setq i (1- i))))
                        'LL
                        'UR
    )
    (setq L1 (cons (vlax-safearray-&amp;gt;list LL) L1)
          L2 (cons (vlax-safearray-&amp;gt;list UR) L2)
    )
  )
  (mapcar '(lambda (a b) (apply 'mapcar (cons a b))) '(min max) (list L1 L2))
)
(vl-load-com)
(princ)
;(c:TBOX)


;;Possibilities??
;;(command "_Select" "W" var1 var2) or some equivalent...?

;;Window

;;default Autocad macro for Select Window toolbar button is:
;;$M=$(if,$(getvar,cmdactive),,_select;)_w &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks for any ideas,&lt;BR /&gt;Steve&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2024 22:57:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12525375#M18540</guid>
      <dc:creator>stev98312</dc:creator>
      <dc:date>2024-01-28T22:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Selection behavior assistance</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12525548#M18541</link>
      <description>&lt;P&gt;one thought I have but only let's user select window once and then the program continues so no more additional selections. Replace these lines of code:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;  (if
    (and (setq sel (ssget))
         (setq box (LM:ssboundingbox sel))
    )&lt;/LI-CODE&gt;&lt;P&gt;with these:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;  (princ "\nSelect Objects by Window")
  (setq p1 (getpoint "\nFirst Corner: "))
  (setq p2 (getcorner p1 "\nSecond Corner: "))
  (if
    (and (setq sel (ssget "_W" p1 p2))
         (setq box (LM:ssboundingbox sel))
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 29 Jan 2024 02:18:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12525548#M18541</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2024-01-29T02:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Selection behavior assistance</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12525888#M18542</link>
      <description>&lt;P&gt;function wp_ssget will always select objects inside a window polygon, based on the coordinates of the &lt;EM&gt;&lt;STRONG&gt;single&lt;/STRONG&gt;&lt;/EM&gt; ssget crossing window or just window. other &lt;EM&gt;&lt;STRONG&gt;single&lt;/STRONG&gt;&lt;/EM&gt; ssget selections will return nil.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun wp_ssget (/ text_sset sset_data)
 	(if (setq text_sset (ssget ":s"))
 		(if (and 
 				 (= -1 (car (setq sset_data (last (ssnamex text_sset)))))
 				 (= 4 (length (cdr sset_data)))
 			)
 			(ssget "_wp" (mapcar 'cadr (cdr sset_data))) 
 			nil
 		)
 	)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 07:43:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12525888#M18542</guid>
      <dc:creator>komondormrex</dc:creator>
      <dc:date>2024-01-29T07:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Selection behavior assistance</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12526282#M18543</link>
      <description>&lt;P&gt;I think I got it working. Not as easy as one could think.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun :windowselect ( / s i l o)
  (setq s (ssadd))
  (while (progn
	   (setvar 'ERRNO 0)
	   (setq o (entsel "\nSelect objects by window: "))
	   (not (and (not o) (= 52 (getvar 'ERRNO))))) ;; right click to quit
    (if o
      (setq l (cons (car o) l))	;; single point selection
      (progn 			;; window selection. getpoint by grrread
	(command "_.select" "_si" "_w" (cadr (grread t 15 0)) pause) ;; single window selection
	(if (setq s (ssget "_p"))
	  (repeat (setq i (sslength s))
	    (setq l (cons (ssname s (setq i (1- i))) l))))))
    (foreach e l (redraw e 3))) ;; highlight current selection
  (if l
    (progn
      (foreach e (reverse l)
	(redraw e 4)
	(ssadd e s))
      (command "_.select" s "") ;; entire selection for select "previous" option
      s)))
&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jan 2024 12:11:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12526282#M18543</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2024-01-29T12:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: Selection behavior assistance</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12526483#M18544</link>
      <description>&lt;P&gt;The big thing that's not clear to me is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you wanting the entire selection to be always by a &lt;EM&gt;single&lt;/EM&gt; window only, but with only Window style, not Crossing, regardless of the direction between picked corners?&amp;nbsp; It looks like Messages 2 &amp;amp; 3 are made to do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But currently your (ssget) in the code lets you do &lt;EM&gt;multiple&lt;/EM&gt; selections under &lt;EM&gt;all the options and methods&lt;/EM&gt; [individual picks, Fence, lasso, Remove option, in addition to both kinds of windowing].&amp;nbsp; Are you wanting that, except to have any variety of windowing always use only Window style and never Crossing style?&amp;nbsp; [I don't know of a way to force that limitation.]&amp;nbsp; In quick trial, it seems Message 4 allows multiple selections, by individual picks and windowing with that limitation and Fence selection, but doesn't seem to allow other options, like lassoing or Remove.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want &lt;EM&gt;all&lt;/EM&gt; the options but windowing to never use Crossing mode, it may not be possible, and may just be a situation where some training is needed, so people are conscious of the need to simply never do windowing [or lassoing] from right to left.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 13:35:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12526483#M18544</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2024-01-29T13:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Selection behavior assistance</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12526706#M18545</link>
      <description>&lt;P&gt;may be coded like this one&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 15:00:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12526706#M18545</guid>
      <dc:creator>komondormrex</dc:creator>
      <dc:date>2024-01-29T15:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Selection behavior assistance</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12527877#M18546</link>
      <description>&lt;P&gt;OKay. A few ways to accomplish this modification.&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1137264"&gt;@paullimapa&lt;/a&gt;- Thank you for such a simple solution. Easy to read, comprehend and incorporate.&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13423916"&gt;@komondormrex&lt;/a&gt;- Couldn't get that one working. No response from the code.&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1779365"&gt;@ВeekeeCZ&lt;/a&gt;- Your WindowSelect is much more programming than I thought would be necessary, but it works and I have a couple other projects I think it'll be perfect for, once I can pick it apart to see how it does what it does.&lt;/P&gt;&lt;P&gt;I want to see if I can incorporate it into this program, too, for the leaning experience.&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;- Apologies. I could have been more clear on my objective. "Are you wanting the entire selection to be always by a single window only, but with only Window style, not Crossing, regardless of the direction between picked corners?" Yes. The current (ssget) is as presented in the original program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all for your help and ideas.&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 00:45:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12527877#M18546</guid>
      <dc:creator>stev98312</dc:creator>
      <dc:date>2024-01-30T00:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Selection behavior assistance</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12527884#M18547</link>
      <description>&lt;P&gt;glad to have helped...cheers!!!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 00:55:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-behavior-assistance/m-p/12527884#M18547</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2024-01-30T00:55:26Z</dc:date>
    </item>
  </channel>
</rss>

