<?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: Filter list/selection by highest property in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10957658#M49017</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8298323"&gt;@jotaferrer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint:&lt;/P&gt;
&lt;P&gt;When you make your list, include an object identifier, such as its handle or vla-object name.&lt;/P&gt;
&lt;P&gt;So your list would look like '((handle_1 . perim_1)(handle_2 . perim_2)...(handle_n . perim_n))&lt;/P&gt;
&lt;P&gt;Then you would sort it via (setq sorted (vl-sort lst '(lambda (a b)(&amp;gt; (cdr a)(cdr b)))))&lt;/P&gt;
&lt;P&gt;and the first one would be the one with the largest perimeter.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Feb 2022 21:41:59 GMT</pubDate>
    <dc:creator>john.uhden</dc:creator>
    <dc:date>2022-02-17T21:41:59Z</dc:date>
    <item>
      <title>Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10953531#M49014</link>
      <description>&lt;P&gt;Hey guys, it's me again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been trying to reach a way to do this, but I just can't figure it out.&lt;/P&gt;&lt;P&gt;As you can see, there's a step in my developing (with&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/564264"&gt;@pbejse&lt;/a&gt;&amp;nbsp; help!)&amp;nbsp;list that I need to filter my selection.&lt;/P&gt;&lt;P&gt;I &lt;STRIKE&gt;need&lt;/STRIKE&gt; want to automatically select the highest perimeter in a list and all other regions that I may have into another list. So that I can subtract to create a region.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is that possible to be done? Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:secm ( / )

 (setq ss (ssget "_A"))

 (command ".region" ss "") ;create region
 
 (setq $ss (ssget "_A"))
 
; (if $ss
;        (repeat (setq i (sslength $ss))
;            (setq lst (cons (vlax-ename-&amp;gt;vla-object (ssname $ss (setq i (1- ;i)))) lst))
;        )
;    ) ; turns ssget a list and vla-object too
    


 (repeat (setq i (sslength $ss))
            (setq lst (cons
			(vlax-get 
				(vlax-ename-&amp;gt;vla-object (ssname $ss (setq i (1- i)))) 'perimeter)
				lst))
        )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 10:04:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10953531#M49014</guid>
      <dc:creator>jotaferrer</dc:creator>
      <dc:date>2022-02-16T10:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10953555#M49015</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8298323"&gt;@jotaferrer&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;I &lt;STRIKE&gt;need&lt;/STRIKE&gt; want to automatically select the highest perimeter in a list and all other regions that I may have into another list.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT size="3"&gt;For starters, Look into &lt;A href="https://documentation.help/AutoLISP-Functions/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-69b1.htm" target="_blank" rel="noopener"&gt;max&lt;/A&gt; or &lt;A href="https://documentation.help/AutoLISP-Functions/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-687f.htm" target="_blank" rel="noopener"&gt;vl-sort&amp;nbsp;&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 10:16:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10953555#M49015</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2022-02-16T10:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10953686#M49016</link>
      <description>&lt;P&gt;So I tried to do an (apply 'max lst) and it does gives me the highest perimeter, but I still trying to "relink" it to its region.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But maybe I can sort the looped list by the highest perimeter... I'll try it!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 11:15:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10953686#M49016</guid>
      <dc:creator>jotaferrer</dc:creator>
      <dc:date>2022-02-16T11:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10957658#M49017</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8298323"&gt;@jotaferrer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint:&lt;/P&gt;
&lt;P&gt;When you make your list, include an object identifier, such as its handle or vla-object name.&lt;/P&gt;
&lt;P&gt;So your list would look like '((handle_1 . perim_1)(handle_2 . perim_2)...(handle_n . perim_n))&lt;/P&gt;
&lt;P&gt;Then you would sort it via (setq sorted (vl-sort lst '(lambda (a b)(&amp;gt; (cdr a)(cdr b)))))&lt;/P&gt;
&lt;P&gt;and the first one would be the one with the largest perimeter.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 21:41:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10957658#M49017</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2022-02-17T21:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10957857#M49018</link>
      <description>&lt;P&gt;&lt;A href="http://www.theswamp.org/index.php?topic=52953.msg577766#msg577766" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;HERE&lt;/STRONG&gt;&lt;/A&gt; is some example code sorting objects ( in this case circles ) then converting to regions and subtracting from the largest.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 23:46:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10957857#M49018</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2022-02-17T23:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10957911#M49019</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/593837"&gt;@ronjonp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I almost never use regions.&amp;nbsp; What happens if you subtract more than the largest?&amp;nbsp; A negative region?&amp;nbsp; A black hole?&lt;/P&gt;
&lt;P&gt;At least we can show him how to sort the sizes in ranges.&amp;nbsp;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 00:13:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10957911#M49019</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2022-02-18T00:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10957916#M49020</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3930636"&gt;@john.uhden&lt;/a&gt;&amp;nbsp; I'd guess black hole depending on your screen color &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 00:18:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10957916#M49020</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2022-02-18T00:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10957944#M49021</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/593837"&gt;@ronjonp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Guess?!&amp;nbsp; Haven't you tried it?&amp;nbsp; I &lt;U&gt;guess&lt;/U&gt; not.&amp;nbsp; It's too big a risk what with "the greys" awaiting at the other end.&lt;/P&gt;
&lt;P&gt;But maybe you would meet Lilu.&amp;nbsp; &amp;lt;Wow, was she hot!&amp;gt;&amp;nbsp; "Multipass, multipass!"&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 00:43:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10957944#M49021</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2022-02-18T00:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10958620#M49022</link>
      <description>So @juhn.uhden that I'm intending to do, but I'm still figuring out how it's possible. But I won't quit my researches, I'll find a way (I think). But if not, I'll ask you guys a little help hehe.&lt;BR /&gt;&lt;BR /&gt;And yeah, you're almost right, subtract by the smallest and you create a worm hole right head to Gargantua! Thanks, now I'm 89 y.o. ‌‌‌‌‌‌‌‌‌‌</description>
      <pubDate>Fri, 18 Feb 2022 10:37:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10958620#M49022</guid>
      <dc:creator>jotaferrer</dc:creator>
      <dc:date>2022-02-18T10:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10958623#M49023</link>
      <description>I'll take a look into it, thans &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/593837"&gt;@ronjonp&lt;/a&gt;</description>
      <pubDate>Fri, 18 Feb 2022 10:37:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10958623#M49023</guid>
      <dc:creator>jotaferrer</dc:creator>
      <dc:date>2022-02-18T10:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10959075#M49024</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8298323"&gt;@jotaferrer&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I'll take a look into it, thans &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/593837"&gt;@ronjonp&lt;/a&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Glad to help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 14:53:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10959075#M49024</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2022-02-18T14:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10959083#M49025</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3930636"&gt;@john.uhden&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/593837"&gt;@ronjonp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Guess?!&amp;nbsp; Haven't you tried it?&amp;nbsp; I &lt;U&gt;guess&lt;/U&gt; not.&amp;nbsp; It's too big a risk what with "the greys" awaiting at the other end.&lt;/P&gt;
&lt;P&gt;But maybe you would meet Lilu.&amp;nbsp; &amp;lt;Wow, was she hot!&amp;gt;&amp;nbsp; "Multipass, multipass!"&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3930636"&gt;@john.uhden&lt;/a&gt;&amp;nbsp; I did try it and the code did not fail. I ended up with nothing or negative matter which I could not see :).&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 14:56:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10959083#M49025</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2022-02-18T14:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10959554#M49026</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/593837"&gt;@ronjonp&lt;/a&gt; wrote, "&lt;SPAN&gt;&amp;nbsp;negative matter which I could not see"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Just think.&amp;nbsp; You could tell Kent's cousin Sheldon Cooper that you can create negative matter with AutoLisp.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Of course the downside of that is that he might befriend you.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 18:12:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10959554#M49026</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2022-02-18T18:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10962981#M49027</link>
      <description>&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3930636"&gt;@john.uhden&lt;/a&gt; Can you please tell me what am I doing wrong!? I'm pretty new with lisp and both mapcar and lambda functions are obscure to me...&lt;BR /&gt;&lt;BR /&gt;(defun c:jsm (/ ss p1 MoIx l $ss i lst 1st 2nd perim)&lt;BR /&gt;&lt;BR /&gt;(vl-load-com)&lt;BR /&gt;&lt;BR /&gt;(setvar "cmdecho" 0)&lt;BR /&gt;&lt;BR /&gt;(setq ss (ssget "_A"))&lt;BR /&gt;&lt;BR /&gt;(command ".region" ss "") ;create region&lt;BR /&gt;&lt;BR /&gt;(setq $ss (ssget "_A"))&lt;BR /&gt;&lt;BR /&gt;(if $ss&lt;BR /&gt;(repeat (setq i (sslength $ss))&lt;BR /&gt;(setq lst (cons (vlax-ename-&amp;gt;vla-object (ssname $ss (setq i (1- i)))) lst))&lt;BR /&gt;)&lt;BR /&gt;) ; turns ssget a list and vla-object too&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;(setq 1st (list (cons 5 (nth 0 lst)) (cons 140 (vla-get-Perimeter (nth 0 lst)))))&lt;BR /&gt;(setq 2nd (list (cons 5 (nth 1lstT)) (cons 140 (vla-get-Perimeter (nth 1 lst)))))&lt;BR /&gt;(setq perim (append 1st 2nd))&lt;BR /&gt;&lt;BR /&gt;(setq sorted (vl-sort perim '(lambda (1st 2dn)(&amp;gt; (cdr 1st)(cdr 2nd)))))</description>
      <pubDate>Mon, 21 Feb 2022 15:04:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10962981#M49027</guid>
      <dc:creator>jotaferrer</dc:creator>
      <dc:date>2022-02-21T15:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10963036#M49028</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8298323"&gt;@jotaferrer&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;....&lt;BR /&gt;(setq 1st (list (cons 5 (nth 0 lst)) (cons 140 (vla-get-Perimeter (nth 0 lst)))))&lt;BR /&gt;(setq 2nd (list (cons 5 (nth &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;1lstT&lt;/FONT&gt;&lt;/STRONG&gt;)) (cons 140 (vla-get-Perimeter (nth 1 lst)))))&lt;BR /&gt;....&lt;BR /&gt;(setq sorted (vl-sort perim '(lambda (1st 2&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;dn&lt;/FONT&gt;&lt;/STRONG&gt;)(&amp;gt; (cdr 1st)(cdr 2nd)))))&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;At the least, the &lt;FONT color="#FF0000"&gt;red&lt;/FONT&gt; parts will cause problems....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I also wonder what you're really going for.&amp;nbsp; For example, the&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt; (cons 5)&lt;/FONT&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;part would typically be about an entity &lt;STRONG&gt;handle&lt;/STRONG&gt;, not a &lt;STRONG&gt;VLA object&lt;/STRONG&gt; that is what you're pairing it with.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Feb 2022 15:40:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10963036#M49028</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2022-02-21T15:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10963078#M49029</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8298323"&gt;@jotaferrer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well, you've got a couple of typos but they don't matter because we are changing your code below, but I'm concerned about your ssget with no filter.&lt;/P&gt;
&lt;P&gt;Do you know for sure that all your objects have a perimeter property?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;(defun c:jsm (/ ss p1 MoIx l $ss i lst 1st 2nd perim)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(vl-load-com)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(setvar "cmdecho" 0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(setq ss (ssget "_A"))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(command ".region" ss "") ;create region&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(setq $ss (ssget "_A"))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(if $ss&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(repeat (setq i (sslength $ss))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(setq lst (cons (vlax-ename-&amp;gt;vla-object (ssname $ss (setq i (1- i)))) lst))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;) ; turns ssget a list and vla-object too&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;;; There's no sense in adding codes to your list because it messes up your sorting&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;;; In fact there's no need to sort if all you have are two (2) objects, but that's okay.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;;; BUT, you don't sort two separate lists.&amp;nbsp; You sort one list, which you have (all objects).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;;; So...&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;(setq sorted (vl-sort lst '(lambda (a b)(&amp;gt; (vla-get-perimeter a)(vla-get-perimeter b)))))&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;;;&amp;nbsp; What that returns is still the same list of objects but sorted in descending order of perimeter.&lt;BR /&gt;;; To get the actual largest perimeter, use...&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;(setq maxperim (vla-get-perimeter (car sorted)))&lt;BR /&gt;&lt;BR /&gt;&lt;STRIKE&gt;(setq 1st (list (cons 5 (nth 0 lst)) (cons 140 (vla-get-Perimeter (nth 0 lst)))))&lt;/STRIKE&gt;&lt;BR /&gt;&lt;STRIKE&gt;(setq 2nd (list (cons 5 (nth 1&lt;FONT color="#FF0000"&gt; lst&lt;/FONT&gt;)) (cons 140 (vla-get-Perimeter (nth 1 lst)))))&lt;/STRIKE&gt;&lt;BR /&gt;&lt;STRIKE&gt;(setq perim (append 1st 2nd))&lt;/STRIKE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRIKE&gt;(setq sorted (vl-sort perim '(lambda (1st 2&lt;FONT color="#FF0000"&gt;nd&lt;/FONT&gt;)(&amp;gt; (cdr 1st)(cdr 2nd)))))&lt;/STRIKE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Feb 2022 16:01:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10963078#M49029</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2022-02-21T16:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10963120#M49030</link>
      <description>hey &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt; thanks for your reply&lt;BR /&gt;&lt;BR /&gt;I'll try to figure out why the red parts will cause problems, thanks!&lt;BR /&gt;&lt;BR /&gt;So, I'm developing a code that will give me the section modulus for any shape. My lisp does work but only if there is no hole whitin the region...&lt;BR /&gt;I know that's so much easier for the user to just subtract the regions and make the final region (with hole or holes) by themselves, but while I'm write this lisp with all you guys help, I'm learning and improving my knowledges.&lt;BR /&gt;&lt;BR /&gt;"CONS 5" was my first thought of what &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3930636"&gt;@john.uhden&lt;/a&gt; told me to do. No need to say I'm pretty new on lisps as well haha</description>
      <pubDate>Mon, 21 Feb 2022 16:21:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10963120#M49030</guid>
      <dc:creator>jotaferrer</dc:creator>
      <dc:date>2022-02-21T16:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: Filter list/selection by highest property</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10963141#M49031</link>
      <description>There's no filter in my ssget because we always open a new dwg and draw what we want in order to get the section modulus. So that's why...&lt;BR /&gt;&lt;BR /&gt;I was thinking about sorting because there's a possible to have more than two regions, it's a small possibility, but we can skip it if is too complicated. At least for me this lisp is driving me crazy haha&lt;BR /&gt;&lt;BR /&gt;Thanks for all your tips!</description>
      <pubDate>Mon, 21 Feb 2022 16:29:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filter-list-selection-by-highest-property/m-p/10963141#M49031</guid>
      <dc:creator>jotaferrer</dc:creator>
      <dc:date>2022-02-21T16:29:39Z</dc:date>
    </item>
  </channel>
</rss>

