<?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: Script\macro that will delete layers in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6458817#M130231</link>
    <description>&lt;P&gt;I am no longer getting the nils, however it is not deleting any layers. The file I am testing it on has most of those layers.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jul 2016 23:11:06 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-07-25T23:11:06Z</dc:date>
    <item>
      <title>Script\macro that will delete layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6458334#M130227</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on a script that I will eventually turn into a macro for my cui. The purpose of the script is to delete certains layers that are in an Architect's Revit export that my engineers never need to see in the files that they use for xrefs. I know that laydel can delete the layer but it will not cycle through if the layers do not exist. Is it possible to do a if layer exists delete it&amp;nbsp; for a macro/script? If not, how would I handle it within a lisp? see below for the script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;PRE&gt;-LAYDEL
n
a-anno-keyn
n
a-anno-dims
n
a-wall-patt
n
g-anno-note
n
g-anno-symb
n
a-wall-iden
n
g-anno-text
n
a-anno-symb

y
-layer
c
8
**

setbylayer
all

y
y
-overkill
all

d
-purge
all

n&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jul 2016 19:04:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6458334#M130227</guid>
      <dc:creator>will.wydock</dc:creator>
      <dc:date>2016-07-25T19:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Script\macro that will delete layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6458406#M130228</link>
      <description>&lt;P&gt;Give this a try. Something very basic and can be improved.&lt;/P&gt;
&lt;PRE&gt;(defun c:custlaydel (/ laylst laycollobj)
  (vl-load-com)
  (setq laycollobj (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))
  (vlax-map-collection laycollobj
                       '(lambda (x) (setq laylst (append (list (vla-get-name x)) laylst)))
  ) ;_ end vlax-map-collection
  (mapcar '(lambda (x)
             (if (member x laylst)
               (command "._-laydel" "n" x "" "")
             ) ;_ end if
           ) ;_ end lambda
          '("a-anno-keyn"       "a-anno-dims"       "a-wall-patt"
            "g-anno-note"       "g-anno-symb"       "a-wall-iden"
            "g-anno-text"       "a-anno-symb"
           )
  ) ;_ end mapcar
) ;_ end defun
&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jul 2016 19:46:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6458406#M130228</guid>
      <dc:creator>Ranjit_Singh</dc:creator>
      <dc:date>2016-07-25T19:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Script\macro that will delete layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6458767#M130229</link>
      <description>&lt;P&gt;Thanks, but when I tried using the routine you sent, I get the response (nil nil nil nil nil nil nil nil).&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 22:46:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6458767#M130229</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-25T22:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: Script\macro that will delete layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6458776#M130230</link>
      <description>&lt;P&gt;Just add a (princ) at the end and you will not get the echo.&amp;nbsp;The routine works though, right?&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;nbsp;(defun c:custlaydel (/ laylst laycollobj)&lt;BR /&gt;&amp;nbsp; (vl-load-com)&lt;BR /&gt;&amp;nbsp; (setq laycollobj (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))&lt;BR /&gt;&amp;nbsp; (vlax-map-collection laycollobj&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '(lambda (x) (setq laylst (append (list (vla-get-name x)) laylst)))&lt;BR /&gt;&amp;nbsp; ) ;_ end vlax-map-collection&lt;BR /&gt;&amp;nbsp; (mapcar '(lambda (x)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (if (member x laylst)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (command-s "._-laydel" "n" x "" "y")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ) ;_ end if&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ) ;_ end lambda&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '("a-anno-keyn"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "a-anno-dims"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "a-wall-patt"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "g-anno-note"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "g-anno-symb"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "a-wall-iden"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "g-anno-text"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "a-anno-symb"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;BR /&gt;&amp;nbsp; ) ;_ end mapcar&lt;BR /&gt;(princ)&lt;BR /&gt;) ;_ end defun&lt;/PRE&gt;
&lt;P&gt;There was an error. I fixed it. "y" in the command-s&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 23:07:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6458776#M130230</guid>
      <dc:creator>Ranjit_Singh</dc:creator>
      <dc:date>2016-07-25T23:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Script\macro that will delete layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6458817#M130231</link>
      <description>&lt;P&gt;I am no longer getting the nils, however it is not deleting any layers. The file I am testing it on has most of those layers.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 23:11:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6458817#M130231</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-25T23:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: Script\macro that will delete layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6458820#M130232</link>
      <description>&lt;P&gt;Try the updated routine. I edited it. This was the correction (command-s "._-laydel" "n" x "" "y")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:custlaydel (/ laylst laycollobj)
  (vl-load-com)
  (setq laycollobj (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))
  (vlax-map-collection laycollobj
                       '(lambda (x) (setq laylst (append (list (vla-get-name x)) laylst)))
  ) ;_ end vlax-map-collection
  (mapcar '(lambda (x)
             (if (member x laylst)
               (command-s "._-laydel" "n" x "" "y")
             ) ;_ end if
           ) ;_ end lambda
          '("a-anno-keyn"       "a-anno-dims"       "a-wall-patt"
            "g-anno-note"       "g-anno-symb"       "a-wall-iden"
            "g-anno-text"       "a-anno-symb"
           )
  ) ;_ end mapcar
(princ)
) ;_ end defun&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jul 2016 23:12:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6458820#M130232</guid>
      <dc:creator>Ranjit_Singh</dc:creator>
      <dc:date>2016-07-25T23:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: Script\macro that will delete layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6459371#M130233</link>
      <description>&lt;P&gt;Hi Ranjit.Singh&lt;BR /&gt;We don't need to get Acad Object, get Active Document, get Layer collection, create a list with all layer nemes in Layer collection, test if layer exist with 'member' that will return a list and if many layers will be slow... testing with vl-position It would be faster...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest something like this:&lt;/P&gt;
&lt;P&gt;(untested)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:demo nil
    (foreach lay '("a-anno-keyn" "a-anno-dims" "a-wall-patt" "g-anno-note" "g-anno-symb" "a-wall-iden" "g-anno-text" "a-anno-symb")
        (if (tblobjname "layer" lay)
            (command "_.-laydel" "_N" lay "" "_Y")
        )
    )
    (princ)
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps, &lt;BR /&gt;Henrique&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2016 08:58:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6459371#M130233</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2016-07-26T08:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: Script\macro that will delete layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6459964#M130234</link>
      <description>&lt;P&gt;I agree.&amp;nbsp;Using tblobjname is much&amp;nbsp;quicker and concise. I will have to update a few of my routines now &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2016 14:18:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/6459964#M130234</guid>
      <dc:creator>Ranjit_Singh</dc:creator>
      <dc:date>2016-07-26T14:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: Script\macro that will delete layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/8235050#M130235</link>
      <description>&lt;P&gt;Dear all, I need a simple script or lisp file to delete a particular layer called 'M-Rev cloud' . and before deleting the layer I need to change the current layer to '0'.&amp;nbsp; Thank you.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3261555"&gt;@Ranjit_Singh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I agree.&amp;nbsp;Using tblobjname is much&amp;nbsp;quicker and concise. I will have to update a few of my routines now &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 12:04:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/8235050#M130235</guid>
      <dc:creator>pramodjoseph</dc:creator>
      <dc:date>2018-08-30T12:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: Script\macro that will delete layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/8235310#M130236</link>
      <description>&lt;PRE&gt;-layer;set;0;;-laydel;n;M-Rev cloud;;y;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Aug 2018 13:27:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/8235310#M130236</guid>
      <dc:creator>will.wydock</dc:creator>
      <dc:date>2018-08-30T13:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Script\macro that will delete layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/8275778#M130237</link>
      <description>&lt;P&gt;This script works perfectly for finding the listed layers and removing them all. Unfortunately I want to delete a handful of layers but I wont always know the full name of the layer. So instead of changing the script for every file I work on, is there a script to delete multiple layers containing the word "CHANGE"? I know the word "CHANGE" will be common for all projects I work on.&lt;/P&gt;&lt;P&gt;ex of Layers. "CHANGES KIT"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"CHANGES"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;"CHANGES_520"&lt;/P&gt;&lt;P&gt;Also if possible how would I auto run the .lsp for all drawings in my drawing package. Instead of typing appload.... on every drawing individually?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 15:07:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-macro-that-will-delete-layers/m-p/8275778#M130237</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-18T15:07:52Z</dc:date>
    </item>
  </channel>
</rss>

