+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Junior Member
    Using
    Architecture 2011
    Join Date
    Jul 2009
    Posts
    15

    Default layer merge command line

    Registered forum members do not see this ad.

    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?

  2. #2
    Super Moderator rkmcswain's Avatar
    Computer Details
    rkmcswain's Computer Details
    Operating System:
    Windows 7 Pro x64
    Computer:
    HP ZBook 17
    CPU:
    i7-4810MQ @ 2.80 GHZ
    RAM:
    16GB
    Graphics:
    Nvidia Quadro K4100M
    Primary Storage:
    256GB SSD
    Secondary Storage:
    1TB SATA
    Monitor:
    (2) HP 23"
    Discipline
    Civil
    rkmcswain's Discipline Details
    Discipline
    Civil
    Details
    CAD Manager
    Using
    Civil 3D 2017
    Join Date
    Sep 2005
    Location
    Houston
    Posts
    4,456

    Default

    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")
    )
    R.K. McSwain
    CAD Panacea | twitter

  3. #3
    Junior Member
    Using
    Architecture 2011
    Join Date
    Jul 2009
    Posts
    15

    Default

    Quote Originally Posted by rkmcswain View Post
    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")
    )
    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.

  4. #4
    Super Moderator rkmcswain's Avatar
    Computer Details
    rkmcswain's Computer Details
    Operating System:
    Windows 7 Pro x64
    Computer:
    HP ZBook 17
    CPU:
    i7-4810MQ @ 2.80 GHZ
    RAM:
    16GB
    Graphics:
    Nvidia Quadro K4100M
    Primary Storage:
    256GB SSD
    Secondary Storage:
    1TB SATA
    Monitor:
    (2) HP 23"
    Discipline
    Civil
    rkmcswain's Discipline Details
    Discipline
    Civil
    Details
    CAD Manager
    Using
    Civil 3D 2017
    Join Date
    Sep 2005
    Location
    Houston
    Posts
    4,456

    Default

    Quote Originally Posted by hrehor View Post
    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.
    R.K. McSwain
    CAD Panacea | twitter

  5. #5
    Forum Deity
    Using
    Civil 3D 2008
    Join Date
    Sep 2006
    Location
    Pittsburgh, PA, USA
    Posts
    3,581

    Default

    Quote Originally Posted by hrehor View Post
    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.

  6. #6
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2013
    Join Date
    Apr 2008
    Posts
    6,199

    Default

    It probably has to do with laymrg trying and not being able to merge 0 with 0.
    Try this (untested)...

    Code:
    (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
    DropBox
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  7. #7
    Forum Newbie
    Discipline
    Architectural
    Using
    Revit 2017
    Join Date
    Aug 2017
    Posts
    1

    Default

    Registered forum members do not see this ad.

    Hi.
    I will merge all layers with _dwg to my_Layer .
    Can i do it with this code?

Similar Threads

  1. VBA merge layers....copy content of a layer to other layer
    By faith_cad in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 17th Dec 2009, 07:01 pm
  2. layer merge
    By reyems in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 12th Jun 2009, 08:50 pm
  3. Layer Merge not working
    By reyems in forum AutoCAD Beginners' Area
    Replies: 11
    Last Post: 18th Mar 2009, 09:40 pm
  4. Automatic Layer change from command line in one step
    By sky girl in forum AutoCAD General
    Replies: 2
    Last Post: 7th Jan 2009, 05:50 am
  5. Using layer manager (LMAN in command line) and layout tabs
    By wbsherlock in forum AutoCAD Drawing Management & Output
    Replies: 8
    Last Post: 26th Mar 2008, 07:37 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts