hrehor Posted February 22, 2010 Posted February 22, 2010 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? Quote
rkmcswain Posted February 22, 2010 Posted February 22, 2010 You may have to do something like this, where you iterate the layer collection, feeding each layer name into the LAYMRG command. (vlax-for x (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object))) (command "._laymrg" "_N" (vla-get-Name x) "" "_N" "0" "_Y") ) Quote
hrehor Posted February 22, 2010 Author Posted February 22, 2010 You may have to do something like this, where you iterate the layer collection, feeding each layer name into the LAYMRG command. (vlax-for x (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object))) (command "._laymrg" "_N" (vla-get-Name x) "" "_N" "0" "_Y") ) thanks RK. it does work, of course :-) though it acts strangely, notepad starts up, when command evoked. i have a shortcut "n" set to launch notepad, but in this case it shouldn't start, since it is not evoked anywhere. could you please give me some idea why * wouldn't work particulary in this command? I always like to get a fishing rod instead of a fish. Quote
rkmcswain Posted February 22, 2010 Posted February 22, 2010 could you please give me some idea why * wouldn't work particulary in this command? I suppose because whoever wrote the code didn't allow for it. This is an old 'Bonus Tool' and not originally part of AutoCAD's internal code - so you can expect some differences. Quote
lpseifert Posted February 22, 2010 Posted February 22, 2010 could you please give me some idea why * wouldn't work particulary in this command? I suppose because whoever wrote the code didn't allow for it. It probably isn't allowed because * would select all layers, including the current one- you can't merge the current layer. Quote
alanjt Posted February 22, 2010 Posted February 22, 2010 It probably has to do with laymrg trying and not being able to merge 0 with 0. Try this (untested)... (setvar 'clayer "0") (vlax-for x (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object))) (or (eq (vla-get-name x) "0") (command "._laymrg" "_N" (vla-get-Name x) "" "_N" "0" "_Y") ) ;_ or ) ;_ vlax-for Quote
kodat Posted August 3, 2017 Posted August 3, 2017 Hi. I will merge all layers with _dwg to my_Layer . Can i do it with this code? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.