<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
<title>What’s the command line layer merge</title>
<link>http://www.zwsoft.com/forum/viewthread.php?tid=2260</link>
<description>I am looking for a script solution to merge all layers to layer 0.
First I unlock all layers and switch to layer 0.
My srcipt looks like this:

(defun c:lm0 ()
(command &quot;._LAYER&quot; &quot;_UNLOCK&quot; &quot;*&quot; &quot;&quot;)
(command &quot;._LAYER&quot; &quot;_THAW&quot; &quot;*&quot; &quot;&quot;)
(command &quot;._LAYER&quot; &quot;_ON&quot; &quot;*&quot; &quot;&quot;)
(command &quot;._LAYER&quot; &quot;_ON&quot; &quot;0&quot; &quot;_UNLOCK&quot; &quot;0&quot; &quot;_THAW&quot; &quot;0&quot; &quot;S&quot; &quot;0&quot; &quot;&quot;)
(command &quot;._LAYMRG&quot; &quot;N&quot; &quot;*&quot; &quot;&quot; &quot;N&quot; &quot;0&quot;)
(princ)
)
Problem is that -laymrg will not accept * to select all layers.
How can you do that?</description>
<author>AlanCullen</author>
<pubDate>2012-07-11 17:32:55</pubDate>
<item><link>http://www.zwsoft.com/forum/viewthread.php?tid=2260&amp;pid=15368</link>
<description>You may have to do something like this, where you iterate the layer collection, feeding each layer name into the LAYMRG command.
 


Code:
(vlax-for
  x
  (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
  (command &quot;._laymrg&quot; &quot;_N&quot; (vla-get-Name x) &quot;&quot; &quot;_N&quot; &quot;0&quot; &quot;_Y&quot;)
)</description>
<author>MKKCAD</author>
<pubDate>2012-07-11 17:48:09</pubDate>
</item>  </channel>
</rss>