hrehor Posted February 22, 2010 Share 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 Link to comment Share on other sites More sharing options...
rkmcswain Posted February 22, 2010 Share 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 Link to comment Share on other sites More sharing options...
hrehor Posted February 22, 2010 Author Share 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 Link to comment Share on other sites More sharing options...
rkmcswain Posted February 22, 2010 Share 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 Link to comment Share on other sites More sharing options...
lpseifert Posted February 22, 2010 Share 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 Link to comment Share on other sites More sharing options...
alanjt Posted February 22, 2010 Share 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 Link to comment Share on other sites More sharing options...
kodat Posted August 3, 2017 Share Posted August 3, 2017 Hi. I will merge all layers with _dwg to my_Layer . Can i do it with this code? Quote Link to comment Share on other sites More sharing options...
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.