+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Senior Member
    Using
    AutoCAD 2008
    Join Date
    Dec 2007
    Posts
    130

    Default Change current layer and selection set to layer 0..

    Registered forum members do not see this ad.

    Hi All,

    I want a quick LISP command to change the current layer to 0 but not just do that, i want to be able to select objects first to change, so it changes all selected objects and the drawing's current layer to 0. I've tried this code out but it won't work (not the changing slected objects bit anyway)....any ideas on what i'm doing wrong or a better solution to my code?

    Code:
    ; SET OBJECTS AND CURRENT LAYER TO 0..
    (defun C:00 ()
      (setq a (cadr (ssgetfirst)))  
      (if a (command "-LAYER" "S" " " a "S" "0" ""))
      (princ)
    )
    Thanks,
    Cheers,

    PaulRenegade @ hardwiredstudios..
    XP Pro / AutoCAD 2007 : Pentium Core 2 Q6600 Quad Core : ASUS P5N-E SLI Motherboard : 4GB DDR2 RAM : 2 x SLI NVIDIA 8500GT SLi 1024MB DDR2 PCI-Express Graphics Cards

  2. #2
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,115

    Default

    oops.. wrong thread

    anyhoo...

    Edit: I was called away when i was about to reply to another thread but somebody mess with my station.. serves me right not locking my desktop
    Last edited by pBe; 5th Jan 2011 at 12:50 pm.

  3. #3
    Super Member David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    1,926

    Default

    maybe:
    Code:
    (defun c:oo (/ ss)
      (while (not ss)
             (princ "\nSelect Entites To Change To Layer 0")
             (setq ss (ssget)))
      (command "_.LAYER" "_UNlock" "0" "_Thaw" "0" "_ON" "0" "_Set" "0" ""
               "_.CHPROP" ss "" "_LA" "0" "")
      (prin1))
    I wouldn't recommend using numeric characters ( if that is what they are ) as the leading character or all characters in a function name. I couldn't tell if they were zeros or the letter O. -David
    R12 (Dos) - A2K

  4. #4
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,635

    Default

    Or if you want to use the pre-selection:
    Code:
    (defun C:00 (/ a)
      (if (setq a (cadr (ssgetfirst)))
        (command "_.change" a "" "_Properties" "_LAyer" "0" "")
      )
      (command "_.LAYER" "_Set" "0" "")
      (princ)
    )

  5. #5
    Senior Member
    Computer Details
    VVA's Computer Details
    Operating System:
    Windows 7
    CPU:
    Intel Core i5-2400
    RAM:
    8 Gb
    Graphics:
    Nvidia Quadro 600
    Primary Storage:
    Seagate 500 GB + WD 750 GB
    Monitor:
    Philips 27"
    Using
    AutoCAD 2013
    Join Date
    Dec 2006
    Location
    Minsk, Belarus
    Posts
    401

    Default

    Registered forum members do not see this ad.

    #3 + #4 = #5
    Code:
    (defun C:00 ( / ss)
      (if (or (setq ss (cadr (ssgetfirst)))
              (and (princ "\nSelect Entites To Change To Layer 0")
                   (setq ss (ssget "_:L"))
                   )
              )
        (command "_.LAYER" "_UNlock" "0" "_Thaw" "0" "_ON" "0" "_Set" "0" ""
               "_.CHPROP" ss "" "_LA" "0" "")
      )
      (princ)
    )

Similar Threads

  1. Replies: 2
    Last Post: 15th Oct 2009, 11:10 am
  2. current layer change
    By hokie555 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 14th Oct 2009, 09:40 pm
  3. By layer objects - change layer but keep colour?
    By Connect Project Tech in forum AutoCAD General
    Replies: 5
    Last Post: 9th Jan 2009, 05:49 pm
  4. Change Layer Prefixs and Layer Names
    By ML0940 in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 9th Jul 2008, 11:11 am
  5. Change layer and return to layer using button
    By Vigilante in forum AutoCAD General
    Replies: 19
    Last Post: 6th Sep 2007, 07:01 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