<?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: Invert Selection Set in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/6597173#M128128</link>
    <description>Perfect thank you</description>
    <pubDate>Sun, 02 Oct 2016 20:19:11 GMT</pubDate>
    <dc:creator>Kyudos</dc:creator>
    <dc:date>2016-10-02T20:19:11Z</dc:date>
    <item>
      <title>Invert Selection Set</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/6593517#M128125</link>
      <description>&lt;P&gt;I'm looking for some LISP to invert the AutoCAD selection - deselect all selected items, and select all those not selected (forming a new selection set). Ideally, it would only work on the current selection (the PICKFIRST selection).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I found this on another board:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:invss (/ ss ss2 n)
  (setq	ss  (ssget)
    ss2 (ssget "_x")
  )
  (if ss
    (progn
      (repeat (setq n (sslength ss))
        (ssdel (ssname ss (setq n (1- n))) ss2)
      )
      (if ss2
        (sssetfirst nil ss2)
      )
    )
  )
)&lt;/PRE&gt;
&lt;P&gt;But it doesn't seem to work properly. Knowing nothing about LISP I haven't a clue why.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers:)&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2016 00:25:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/6593517#M128125</guid>
      <dc:creator>Kyudos</dc:creator>
      <dc:date>2016-09-30T00:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Invert Selection Set</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/6593785#M128126</link>
      <description>&lt;P&gt;For me it works, although I did some modifications...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun c:invss ( / ss ss2 n )
  (setq	ss (ssget)
    ss2 (ssget "_X")
  )
  (if ss
    (repeat (setq n (sslength ss))
      (ssdel (ssname ss (setq n (1- n))) ss2)
    )
  )
  (if ss2
    (sssetfirst nil ss2)
  )
  (princ)
)&lt;/PRE&gt;&lt;P&gt;M.R.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2016 05:06:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/6593785#M128126</guid>
      <dc:creator>marko_ribar</dc:creator>
      <dc:date>2016-09-30T05:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: Invert Selection Set</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/6594490#M128127</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/542776"&gt;@Kyudos&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I'm looking for some LISP to invert the AutoCAD selection - deselect all selected items, and select all those not selected (forming a new selection set). Ideally, it would only work on the current selection (the PICKFIRST selection).&lt;/P&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Here's my take on it -- very lightly tested, but it works in noun-verb &lt;EM&gt;or&lt;/EM&gt; verb-noun mode [i.e. if you have anything pre-selected when you enter the command, it selects/grips/highlights everything except that pre-selection, or if you don't, it asks you to select objects, then selects/grips/highlights everything except those].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun C:SAB (/ ss); = Select All But
  (setq ss
    (cond
      ((ssget "_I")); preselection, if any
      ((ssget)); User selection if no pre-selection
    ); cond
  ); setq
  (sssetfirst nil); clear preselection, if any, to not to in at Select command
  (command "_.select" "_all" "_remove" ss "")
  (sssetfirst nil (ssget "_P")); select/grip/highlight
); defun&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add an appropriate prompt if desired, and/or put the final selection into a variable if needed, etc.&amp;nbsp; If you really want it to work only with a pre-selection, isolate that out of the (cond) function and dump the User-selection part.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It has a slightly different effect than the versions using (ssget "_X"), since those will find &lt;EM&gt;everything in the drawing&lt;/EM&gt;, even in other than the current space, whereas this will work only with things in the current space.&amp;nbsp; Depending on what you plan to do with the result, that may be preferable, anyway.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT:&amp;nbsp; In fact, if you want it to work &lt;EM&gt;only&lt;/EM&gt; with pre-selection, there isn't even any need for&amp;nbsp;the 'ss'&amp;nbsp;variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun C:SAB ()
  (if (ssget "_I")
    (progn ; then
      (sssetfirst nil)
      (command "_.select" "_all" "_remove" (ssget "_P") "")
      (sssetfirst nil (ssget "_P"))
    )
    (prompt "\nRequires pre-selection."); else
  ); if
); defun&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Sep 2016 13:32:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/6594490#M128127</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2016-09-30T13:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: Invert Selection Set</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/6597173#M128128</link>
      <description>Perfect thank you</description>
      <pubDate>Sun, 02 Oct 2016 20:19:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/6597173#M128128</guid>
      <dc:creator>Kyudos</dc:creator>
      <dc:date>2016-10-02T20:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Invert Selection Set</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/12995468#M128129</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;Is it possible to modify this routine, so it will consider only selected layer (To invert selection only within layer on which selected object(s) is placed)?&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2024 09:50:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/12995468#M128129</guid>
      <dc:creator>franc_as</dc:creator>
      <dc:date>2024-09-02T09:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Invert Selection Set</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/12995520#M128130</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1114946"&gt;@franc_as&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;.... Is it possible to modify this routine...?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;[Which one?]&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2024 10:39:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/12995520#M128130</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2024-09-02T10:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: Invert Selection Set</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/12995528#M128131</link>
      <description>&lt;P&gt;(defun C:SAB ()&lt;BR /&gt;(if (ssget "_I")&lt;BR /&gt;(progn ; then&lt;BR /&gt;(sssetfirst nil)&lt;BR /&gt;(command "_.select" "_all" "_remove" (ssget "_P") "")&lt;BR /&gt;(sssetfirst nil (ssget "_P"))&lt;BR /&gt;)&lt;BR /&gt;(prompt "\nRequires pre-selection."); else&lt;BR /&gt;); if&lt;BR /&gt;); defun&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2024 10:45:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/12995528#M128131</guid>
      <dc:creator>franc_as</dc:creator>
      <dc:date>2024-09-02T10:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: Invert Selection Set</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/12995604#M128132</link>
      <description>&lt;P&gt;This seems to do that [minimally tested]:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(defun C:SABL (/ ss n lay laylist laystr)
; = Select All But, on pre-selected objects' Layer(s) only
  (if (setq ss (ssget "_I")); pre-selection
    (progn ; then
      (sssetfirst nil); clear selection
      (repeat (setq n (sslength ss)); Layer(s) of selected object(s)
        (setq lay (cdr (assoc 8 (entget (ssname ss (setq n (1- n)))))))
        (if (not (member lay laylist))
          (setq
            laylist (cons lay laylist); for checking if already present
            laystr (strcat (cond (laystr) ("")) lay ","); for (ssget)
          ); setq
        ); if
      ); repeat
      (command "_.select" (ssget "_X" (list (cons 8 laystr))) "_remove" ss "")
      (sssetfirst nil (ssget "_P")); select/grip/highlight
    ); progn
    (prompt "\nRequires pre-selection."); else
  ); if
  (prin1)
); defun&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 02 Sep 2024 11:37:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/12995604#M128132</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2024-09-02T11:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: Invert Selection Set</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/12995662#M128133</link>
      <description>Thank you Kent...it works fine for me</description>
      <pubDate>Mon, 02 Sep 2024 12:06:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/12995662#M128133</guid>
      <dc:creator>franc_as</dc:creator>
      <dc:date>2024-09-02T12:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: Invert Selection Set</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/13263121#M128134</link>
      <description>&lt;P&gt;To invert the selection, a command that every design software has had for decades now, I must code the command myself. No thank you, Autodesk. I am a designer attempting a simple design operation.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 21:00:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/13263121#M128134</guid>
      <dc:creator>rmc9WR3X</dc:creator>
      <dc:date>2025-01-15T21:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Invert Selection Set</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/13266135#M128135</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13414198"&gt;@rmc9WR3X&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;AutoCAD has a litany of shortcomings.&lt;/P&gt;&lt;P&gt;That's why they pay nothing to have brilliant volunteers help provide solutions.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2025 00:05:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/invert-selection-set/m-p/13266135#M128135</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2025-01-17T00:05:18Z</dc:date>
    </item>
  </channel>
</rss>

