lisp routine to check for layer and change entities

Discussion in 'AutoCAD' started by CDT, Jul 21, 2003.

  1. CDT

    CDT Guest

    Hi All,

    I need a lisp routine that will go through a folder of drawing files
    (about 300)and check for the existence of a layer (name: NC, color:
    7), if it does not exist, then create it and change all entities in
    the drawing to be on this layer.

    all help is greatly appreciated.

    Thank You,
    Chris
     
    CDT, Jul 21, 2003
    #1
  2. CDT

    Adam B Guest

    hears a partial routine that will search for a layer and create it if it
    doesn't exist.

    (if (= nil (tblsearch "layer" "NC"))
    (command "-layer" "n" "NC" "c" "7" "")
    )

    i don't have a routine that will search files that aren't currently
    existing.
    however i'm sure that it would be easy enough to make a routine that will
    search a directory for all *.dwg files and load them one by one and close
    them once it has completed the above routine.

    rock on!

    remember its not work, its autocad
     
    Adam B, Jul 21, 2003
    #2
  3. CDT

    Adam B Guest

    wouldn't it be logical randy to first see if you even need to create that
    layer? you only use a few more bytes of hard drive space?
     
    Adam B, Jul 22, 2003
    #3
  4. CDT

    CDT Guest

    thanks guys.

    I've been out of town and am just getting back to this project.

    I understand the code (checking for the layer and the command to
    create the layer).

    (if (= nil (tblsearch "layer" "NC"))
    (command "-layer" "n" "NC" "c" "7" "")
    )


    thing is, in some of the drawings the layer exists. in some it
    doesn't. in others it exists but, the entities are on layer "0"
    instead of "NC". the goal is to get all of the entities in every
    drawing on the "nc" layer.

    The "if" statement seems like it would work the bestthen, right?

    How could I batch process the script or lisp routine on all of the
    drawings in a folder? i know I can type in the location of every
    single file but that's time consuming)..like so:

    sdi
    1
    filedia
    0
    open
    "C:\Program Files\ACAD2000\Drawings\neocase\DRAWING_LIBRARY\10_BASES\10PFB122435.dwg"
    ucsicon
    n
    -layer
    c
    7
    neocase
    s
    neocase

    change
    all

    P
    LA
    nc

    regenall
    ze
    qsave
    close


    (there are some extra viewing things in there)

    I'd hate to have to do this for every one...any ideas?

    thank you again,

    Chris
     
    CDT, Jul 28, 2003
    #4
  5. CDT

    CDT Guest

    Hi Paul,

    Thanks for the link. I'll check it out.

    I want everything on one layer because each drawing file only contains
    a cabinet symbol for a library. When the user inserts these blocks, I
    need the entities on a specific layer (customer request). In large
    architectural drawings, we want to be able to isolate the cabinet
    symbols by turing off, or freezing, all of the other layers, including
    "0".

    Thanks Again,

    Chris
     
    CDT, Jul 30, 2003
    #5
  6. CDT

    CDT Guest


    Placing everything on a company specific layer is based upon an
    existing library the customer wants me to use as a guide. Each drawing
    file contains 2-3 (tops) 3d solids to make up a cabinet.

    I understand about layer "0" but the customer wants to control how
    their symbols appear and what layer they are on in a drawing even if
    they are exploded (which happens when someone wants to create a custom
    configuration to a specific cabinet model..basically they explode the
    block and seperate the unioned 3d solids and then modify things like
    shelf locations and such).

    If you know of a better way or have any suggestions, I'm all ears as
    I'm new to this.

    Thanks,

    Chris
     
    CDT, Jul 31, 2003
    #6
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.