+ Reply to Thread
Page 1 of 5 1 2 3 ... LastLast
Results 1 to 10 of 44
  1. #1
    Junior Member gerbaux's Avatar
    Using
    AutoCAD 2007
    Join Date
    Jun 2008
    Posts
    14

    Unhappy Changing layer by typing the layer name

    Registered forum members do not see this ad.

    I'm quite new here.. so i don/t know if it's correct to ask questions here rather that posting tips.. I'm finding a way to change the current layer by typing the layer name itself without the use of any other command. and i want also to change the layer of a certain object by selecting the objects then typing the layer name.

    I already got a code from somewhere in the net, but i need to command first LS then type the layername i want to make current.. and it can't change the layer of an object instantly. if you want this code, i can't post it for you guys the original code with the authors name.. thank you in advance...

  2. #2
    Super Moderator Cad64's Avatar
    Computer Details
    Cad64's Computer Details
    Operating System:
    Windows 7 Profesional x64
    Computer:
    XI Computers
    Motherboard:
    Asus P8Z77-V Pro
    CPU:
    Intel Core I7 3770K 4.1 Ghz Quad Core 3rd Gen
    RAM:
    24GB DDR3 @ 1333MHz
    Graphics:
    Nvidia GeForce GTX 570 1280MB GDDR5
    Primary Storage:
    SATAII 500GB 7200 RPM
    Secondary Storage:
    Western Digital My Book Studio Edition II - 2TB capacity
    Monitor:
    HPf2105 21" LCD Widescreen & Cintiq 21ux
    Discipline
    Multi-disciplinary
    Cad64's Discipline Details
    Occupation
    Landscape Architect
    Discipline
    Multi-disciplinary
    Using
    3ds Max 2011
    Join Date
    Feb 2006
    Location
    Southern California
    Posts
    9,036

    Default

    This can be done pretty simply by using the code: (setvar "clayer" "Layer1") where "Layer1" is the name of the layer you want to switch to.

    A simple routine to do this would be:

    (defun c:layer1 ()
    (setvar "clayer" "Layer1")
    (princ)
    )

    To activate the command and switch to Layer1, you would just type Layer1 at the command line. This command will only work for this layer though. You would need many of these routines for every layer in your drawing. Is there some reason why you want to work this way, instead of using the layer list box on the "Layers" toolbar?

    You can also use the MATCHPROP command, to select an object and match it's properties to another object, or just select the object and then choose the layer you want to move it to, from the layer list box on the "Layers" toolbar.
    Personal Website: ( Updated 03/21/2014 ) ---> http://www.rdeweese.com/

    "Work Smart, Not Hard"

  3. #3
    Junior Member gerbaux's Avatar
    Using
    AutoCAD 2007
    Join Date
    Jun 2008
    Posts
    14

    Default

    thank you sir for your prompt reply. the reason for this request is because this company im working for is using standard layernames that has 3 characters(1letter and 1-2 numbers).. that is why i feel it's easier if i can just type the layer name to make it active or to change the layer of an object..

  4. #4
    Super Member ASMI's Avatar
    Using
    AutoCAD 2008
    Join Date
    Nov 2005
    Location
    Oceanus Procellarum, Moon
    Posts
    1,427

    Default

    I think:

    Code:
    (defun c:ll(/ lName)
      (if
        (and
          (setq lName(getstring T "\nSpecify layer name: "))
          (tblsearch "LAYER" lName)
          ); end and
        (setvar "CLAYER" lName)
        (princ(strcat "\n<!> Can't to find layer \"" lName "\" <!>"))
        ); end if
      (princ)
      ); end of  c:ll

  5. #5
    Junior Member gerbaux's Avatar
    Using
    AutoCAD 2007
    Join Date
    Jun 2008
    Posts
    14

    Default

    @ASMI

    thank you sir for your reply, but from my basic knowledge of LISP, i understand that i need first to issue the command LL before typing the layer name. please correct me if i'm wrong.

    thankz again for your time...

  6. #6
    Super Member ASMI's Avatar
    Using
    AutoCAD 2008
    Join Date
    Nov 2005
    Location
    Oceanus Procellarum, Moon
    Posts
    1,427

    Default

    Yes, LL and layer name.

  7. #7
    Junior Member gerbaux's Avatar
    Using
    AutoCAD 2007
    Join Date
    Jun 2008
    Posts
    14

    Default

    Quote Originally Posted by ASMI View Post
    Yes, LL and layer name.

    sorry sir, but i'm trying to look for a way, to use the layer name directly..

    thank you again...

  8. #8
    Super Member ASMI's Avatar
    Using
    AutoCAD 2008
    Join Date
    Nov 2005
    Location
    Oceanus Procellarum, Moon
    Posts
    1,427

    Default

    There isn't problem, look for Cad64 message. I have add several strings to Cad64 lisp:

    Code:
     
    (defun c:0(/ lName) ;CHANGE '0' NAME TO LAYER NAME
      (setvar "CMDECHO" 0)
      (if(tblsearch "LAYER"(setq lName "0")) ;CHANGE "0" TO LAYER NAME
        (progn
        (command "_.clayer" lName)
        (princ(strcat "\n<<< Swiched to \"" lName "\" layer >>>"))
        ); end progn
        (princ(strcat "\n<!> Can't to find layer \"" lName "\" <!>"))
        ); end if
      (setvar "CMDECHO" 0)
      (princ)
      ); end of c:0
    It's for "0" layer.

  9. #9
    Junior Member gerbaux's Avatar
    Using
    AutoCAD 2007
    Join Date
    Jun 2008
    Posts
    14

    Default

    thankz sir, i'l try this at home as my office hours ends now.. i'l let you know tomorrow if it worked for me.. thankz!!!!!

  10. #10
    Senior Member GhostRider's Avatar
    Computer Details
    GhostRider's Computer Details
    Operating System:
    Windows Vista Business
    Computer:
    Dell Optiplex 755
    Motherboard:
    Dell
    CPU:
    Intell Core 2 DUO 2.8ghz
    RAM:
    3 GIG
    Graphics:
    Ati RAEDON HD 2400 Dual -512 Ram
    Primary Storage:
    160 Gigger
    Monitor:
    Dual Acer 22"
    Discipline
    Architectural
    GhostRider's Discipline Details
    Occupation
    Residential Engineering/Contracting
    Discipline
    Architectural
    Using
    AutoCAD 2011
    Join Date
    Aug 2007
    Location
    N. Carolina
    Posts
    405

    Default

    Registered forum members do not see this ad.

    A few macro or small lisps added to the ACAD.lsp works well for me with standard layernames in my templetes.

    Something like this you can set your layers on and off as you like, I have my border and titleblock on 0 , but you can set it anyway you need with as many layers on, off , thawed or frozen, as you like...

    Code:
    (DEFUN C:lyr1 ()
      (COMMAND "-LAYER" "T" "LAYERNAME" "S"
        "LAYERNAME" "F" "*" "T"
        "0,LAYERNAME2,defpoints" "")
    So many commands, so little time....

Similar Threads

  1. Changing Layer Color with VB
    By sailor in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 11th Aug 2007, 12:14 pm
  2. Changing Layer Properties
    By steve @ mp in forum AutoLISP, Visual LISP & DCL
    Replies: 12
    Last Post: 12th Jul 2007, 01:26 pm
  3. Changing the Layer
    By El Barto in forum AutoCAD Beginners' Area
    Replies: 5
    Last Post: 25th Oct 2006, 02:40 pm
  4. Changing layer names
    By Alan Cullen in forum AutoCAD Drawing Management & Output
    Replies: 12
    Last Post: 9th Oct 2006, 12:03 am
  5. Changing an objects layer?
    By grev in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 27th Feb 2004, 07:44 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