CAD software discussion forum > CAD Tutorial & Tips > How to merge all layer in autocad or ZWCAD through lisp routine

How to merge all layer in autocad or ZWCAD through lisp routine

Rank: 1

AlanCullen

Newbie

posts: 2

Registered: 2012-7-11

Message 1 of 2

 How to merge all layer in autocad or ZWCAD through lisp routine
11-07-2012 05:32 . pm | View his/her posts only
How to merge all layer in autocad or ZWCAD through lisp routine? 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 "._LAYER" "_UNLOCK" "*" "")
(command "._LAYER" "_THAW" "*" "")
(command "._LAYER" "_ON" "*" "")
(command "._LAYER" "_ON" "0" "_UNLOCK" "0" "_THAW" "0" "S" "0" "")
(command "._LAYMRG" "N" "*" "" "N" "0")
(princ)
)
Problem is that -laymrg will not accept * to select all layers.
How can you do that?

Rank: 1

MKKCAD

Newbie

posts: 10

Registered: 2012-7-11

Message 2 of 2

11-07-2012 05:48 . pm | View his/her posts only
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 "._laymrg" "_N" (vla-get-Name x) "" "_N" "0" "_Y")
)
See also