copy layer

Discussion in 'AutoCAD' started by jb4pres, Jun 29, 2004.

  1. jb4pres

    jb4pres Guest

    is there a lisp that can create a new layer based on an existing layer. I am mapping streets using existing data that is highly inaccurate and creating 2 new layers based on the original.

    Existing - "street"
    New Layers - "street - cen" & "street - edg" for centerline and edge.

    If this can be done Id like to set it up so that the cen's are yellow and the edg's are red everything else remains the same.

    I'm trying to learn this and Help is greatly appreciated!!
     
    jb4pres, Jun 29, 2004
    #1
  2. jb4pres

    Doug Barr Guest

    mapping streets using existing data that is highly inaccurate and creating 2 new
    layers based on the original.
    edg's are red everything else remains the same.

    Here's one way to do it.
    See if you can follow what's going on.
    -doug

    (defun c:copylayer ( / a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 b1 b2 c1)

    (princ "\nPick Layer to copy:") ; this prompts you for something
    (setq a1 (entsel)) ; you select the entity
    (setq a2 (car a1)) ; the name of that entity
    (setq a3 (entget a2)) ; gets data about that entity
    (setq a4 (assoc 8 a3))
    (setq a5 (cdr a4)) ; name of layer you picked
    (setq a6 (tblsearch "LAYER" a5)) ; gets data about that layer
    (setq a7 (assoc 62 a6))
    (setq a8 (cdr a7)) ; color, in case you want it to be the same
    (setq a9 (assoc 6 a6))
    (setq a10 (cdr a9)) ; linetype

    (princ "\nType suffix for layer:")
    (setq b1 (getstring T)) ; the T allows spaces in your typed string
    (setq b2 (strcat a5 b1)) ; concatenates (joins) the name + suffix

    (princ "\nType color for new layer:")
    (setq c1 (getstring T))

    (command "LAYER" "M" b2 "c" c1 bb "lt" a10 b2 "") ; makes the layer
    (princ)
    )
     
    Doug Barr, Jun 29, 2004
    #2
  3. jb4pres

    jb4pres Guest

    that does everything I need but change the color. It asks me what color do i want the new layer, and no matter what i put in its always white. I tried red and 1 and both came back white. Is it a different code for the color?
     
    jb4pres, Jun 30, 2004
    #3
  4. jb4pres

    T.Willey Guest

    In line:
    (command "LAYER" "M" b2 "c" c1 bb "lt" a10 b2 "") ; makes the layer
    change the "bb" to "b2" and see if that works.

    Tim
     
    T.Willey, Jun 30, 2004
    #4
  5. jb4pres

    jb4pres Guest

    That did it!! Thanks!!
     
    jb4pres, Jun 30, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.