<?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: Comparing two lists in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9395803#M77069</link>
    <description>&lt;P&gt;See&lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selecting-xref-with-lisp-vlisp/m-p/2021579/highlight/true#M243330" target="_blank" rel="noopener"&gt; this&lt;/A&gt; post&amp;nbsp; and try to update your code.&lt;/P&gt;</description>
    <pubDate>Tue, 24 Mar 2020 09:22:42 GMT</pubDate>
    <dc:creator>hak_vz</dc:creator>
    <dc:date>2020-03-24T09:22:42Z</dc:date>
    <item>
      <title>Comparing two lists</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9386608#M77059</link>
      <description>&lt;P&gt;Hello!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to do something quite simple - it is just a problem of writing the correct LISP of doing so ...&lt;/P&gt;&lt;P&gt;I need 3 different lists:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;List1 is a list that contains all layers in a drawing;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(defun LayersList ( / )&lt;BR /&gt;(vlax-for lay (vla-get-Layers&lt;BR /&gt;(vla-get-ActiveDocument (vlax-get-acad-object)))&lt;BR /&gt;(setq List1 (cons (vla-get-Name lay) List1))))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think this code is okay as it creates list1 consisting of the layers in the drawing.&lt;/P&gt;&lt;P&gt;Another list (list2) is a comparison list I create and define myself - for now let's say that list2 is put through&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(setq list2 '("1" "2" "3" "A" "B" "C"))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally, I would like to compare the list1 with the list2 and give me the values (layer names) that do comply and the ones that don't comply. The values that don't comply I would like to constitute the third list "list3". I have tried with "member", "mapcar" and a few others without succeeding so far...&lt;/P&gt;&lt;P&gt;Any ways of writing this code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 08:58:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9386608#M77059</guid>
      <dc:creator>thomas.schive</dc:creator>
      <dc:date>2020-03-19T08:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two lists</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9386644#M77060</link>
      <description>&lt;P&gt;Don't understand.&lt;/P&gt;
&lt;P&gt;Give us imaginary examples of lst1, lst2 and desired outcome of lst3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;lst3 is a result of comparison based on what? (hopefully, I could see that from given examples)&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 09:21:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9386644#M77060</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2020-03-19T09:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two lists</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9386767#M77061</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Okay, so let's say that I have in my DWG the current layers with layer names "0" "1" "2" "3" "A" "B" and "C".&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My first list "list1" will then be the layer names listed as above: ("0" "1" "2" "3" "A" "B" "C").&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What I want to is to find the layer names in my drawing (list1) that does not exist in my reference list (list2). The reference list "list2" is defined, as an example:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'("0" "1" "2" "A" "B"). Call it the layer names that&amp;nbsp;&lt;EM&gt;should&amp;nbsp;&lt;/EM&gt;be in the drawing. The ones that differ, in this case "3" and "C" are the layers that are not named correctly according to list2.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want the ones that differ, "3" and "C" in this case, to be written into a list "list3" that is printed to the user to inform the user which layers are not named correctly according to the reference list "list2".&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 10:26:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9386767#M77061</guid>
      <dc:creator>thomas.schive</dc:creator>
      <dc:date>2020-03-19T10:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two lists</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9386797#M77062</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;(setq lst1 '("0" "1" "2" "3" "A" "B" "C"))
(setq lst2 '("0" "1" "2" "A" "B"))
(setq lst3 (vl-remove-if '(lambda (x) (vl-position x lst2)) lst1))

&amp;gt;&amp;gt; ("3" "C")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 10:38:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9386797#M77062</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2020-03-19T10:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two lists</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9386817#M77063</link>
      <description>&lt;LI-CODE lang="markup"&gt;(setq list1 '("0" "1" "2" "3" "A" "B" "C") list2 '("0" "1" "2" "A" "B"))

(foreach el list1 
(if (not (member el list2)) 
       (setq list3 (cons el list3)))
)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 19 Mar 2020 10:46:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9386817#M77063</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-03-19T10:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two lists</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9386871#M77064</link>
      <description>&lt;P&gt;Could not get this one to work, but the answer below with the foreach seems to provide the desired results.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to both!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 11:15:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9386871#M77064</guid>
      <dc:creator>thomas.schive</dc:creator>
      <dc:date>2020-03-19T11:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two lists</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9386906#M77065</link>
      <description>&lt;P&gt;That's unfortunate.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might need (vl-load-com) loaded.&amp;nbsp;Then try&lt;/P&gt;
&lt;P&gt;(vl-remove-if '(lambda (x) (vl-position x '("0" "1" "2" "A" "B"))) '("0" "1" "2" "3" "A" "B" "C"))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Foreach is good to know but mastering lists with such functions is essential! That's what LISP is all about.&lt;/P&gt;
&lt;P&gt;Good luck!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 11:31:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9386906#M77065</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2020-03-19T11:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two lists</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9387003#M77066</link>
      <description>&lt;P&gt;Depending on what you intend to do with that information, it may be that the built-in&amp;nbsp;&lt;A href="http://help.autodesk.com/view/ACD/2020/ENU/?guid=GUID-D64F8076-4978-44B7-B056-D921C77FEA88" target="_blank" rel="noopener"&gt;&amp;gt;CAD Standards&amp;lt;&lt;/A&gt; features can handle it for you.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 12:13:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9387003#M77066</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2020-03-19T12:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two lists</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9395747#M77067</link>
      <description>&lt;P&gt;Hello again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering - relating to this topic, whether the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(defun Layerlist ( / )&lt;BR /&gt;(vlax-for lay (vla-get-Layers&lt;BR /&gt;(vla-get-ActiveDocument (vlax-get-acad-object)))&lt;BR /&gt;(setq List1 (cons (vla-get-Name lay) List1))&lt;BR /&gt;))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could be changed into ONLY listing non-xref layers in List1?&lt;/P&gt;&lt;P&gt;Thanks for your help, very much appreciated!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 09:06:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9395747#M77067</guid>
      <dc:creator>thomas.schive</dc:creator>
      <dc:date>2020-03-24T09:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two lists</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9395784#M77068</link>
      <description>&lt;P&gt;Just test the layer name if it includes *|*. Pretty much the same thing as you used&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/writing-a-list-to-txt-file/m-p/9393840/highlight/true#M397512" target="_blank" rel="noopener"&gt;HERE&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 09:16:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9395784#M77068</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2020-03-24T09:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two lists</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9395803#M77069</link>
      <description>&lt;P&gt;See&lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selecting-xref-with-lisp-vlisp/m-p/2021579/highlight/true#M243330" target="_blank" rel="noopener"&gt; this&lt;/A&gt; post&amp;nbsp; and try to update your code.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 09:22:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/comparing-two-lists/m-p/9395803#M77069</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-03-24T09:22:42Z</dc:date>
    </item>
  </channel>
</rss>

